首页 技术 正文
技术 2022年11月15日
0 收藏 961 点赞 4,396 浏览 6137 个字

EasyDSS相关功能

EasyDSS流媒体服务器软件,提供一站式的转码、点播、直播、时移回放服务,极大地简化了开发和集成的工作。其中,点播版本主要包含:上传、转码、分发。直播版本主要包含:直播、录像,直播支持RTMP输入,RTMP/HLS/HTTP-FLV的分发输出;录像支持自定义保存时长、检索及下载;提供丰富的二次开发接口、基于JSON的封装及HTTP调用;提供播放鉴权、推流鉴权等安全保证;提供用户及相关权限管理配置。

EasyDSS流媒体服务搭建资源

【官网】

【点播版本在线演示】

【直播版本在线演示】

【旗舰版本在线演示】

【在线接口】

这篇博文主要介绍如何利用软件提供的接口快速接入开发。

一、 快速安装

  1. 下载地址
  2. 下载对应环境的安装包
  3. 解压安装包
  4. Windows下双击EasyDSS.exe直接启动
  5. Linux下解压目录执行./start.sh

注:路径中不能包含中文

二、 二次开发

二次开发中,方式是在自己业务系统后端登录接口中,调用流媒体的登录接口,获取所需的sid或是token

1.封闭内网使用

在业务使用,如果只是使用EasyDSS提供视频分发能力,且不会对外公开接口端口10080(默认端口),可以直接将接口鉴权关闭,具体服务器登录 http://demo.easydss.com:10080/login.html 默认用户名/密码 admin/admin, 在基础配置页面,【接口鉴权】开关。

2.业务系统对接

2.1 cookie方式

注: HttpOnly = true 客户端API(例如JavaScript)无法访问仅限http的cookie。 此限制通过跨站点脚本(XSS)消除了cookie被盗的威胁。

  • 在后端业务代码中对接,如Java/PHP/Node.js 等
  • 调用EasyDSS登录接口,接口调用成功后会在请求Headers的cookie中写入sid
  • 取出cookie里的sid
  • 其它接口调用时在请求头cookies中传递sid
  • Content-Type:application/x-www-form-urlencoded
  • 接口请求路径示例:http://localhost:10080/login

代码示例:Java

2.1.1 获取sid
import java.io.DataOutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;public class GetLoginSid {
public static void main(String[] args) throws Exception {
URL url = new URL("http://demo.easydss.com:10080/login"); //发起POST请求,并传递username,password参数(需要md5加密)
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
String content = "username=admin&password=21232f297a57a5a743894a0e4a801fc3";
out.writeBytes(content);
out.flush();
out.close(); Map<String, List<String>> headerFields = conn.getHeaderFields(); Set<String> headerFieldsSet = headerFields.keySet(); Iterator<String> hearerFieldsIter = headerFieldsSet.iterator(); while (hearerFieldsIter.hasNext()) { String headerFieldKey = hearerFieldsIter.next(); if ("Set-Cookie".equalsIgnoreCase(headerFieldKey)) { List<String> headerFieldValue = headerFields.get(headerFieldKey); for (String headerValue : headerFieldValue) {
String[] fields = headerValue.split(";\\s*");
for (int j = 0; j < fields.length; j++) {
if (fields[j].indexOf('=') > 0) {
String[] f = fields[j].split("=");
if ("Expires".equalsIgnoreCase(f[0])) {
System.out.println("Expires:" + f[1]);
}
else if ("Max-Age".equalsIgnoreCase(f[0])) {
System.out.println("Max-Age:" + f[1]);
}else if ("sid".equalsIgnoreCase(f[0])) { //获取sid
System.out.println("sid:" + f[1]);
}
}
}
}
}
}
}
}
运行如下:

2.1.2 携带sid调用其它接口
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;public class RequestOtherAPI {public static void main(String[] args) throws Exception {
URL url = new URL("http://demo.easydss.com:10080/live/list");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
//这里传递上一步获得sid
conn.setRequestProperty("Cookie","sid=s%3Ark-TEuVtm.WnWoXuDY%2FldJuEc64I6TXjd0Fq1eqByEd4ng1UwNb2I;");
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
String content = "start=0&limit=10";
out.writeBytes(content);
out.flush();
out.close(); conn.connect();
StringBuffer sbf = new StringBuffer();
InputStream is = conn.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String strRead = null;
while ((strRead = reader.readLine()) != null) {
sbf.append(strRead);
sbf.append("\r\n");
}
reader.close();
System.out.println(sbf.toString());
}
}
运行如下

2.2 token方式

  • 调用登录接口获取token
  • Content-Type:application/x-www-form-urlencoded
  • 其它接口调用时传递附加token入参
代码示例:Java
2.2.1 获取token
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;public class GetLoginToken {public static void main(String[] args) throws Exception {
URL url = new URL("http://localhost:10080/login");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
String content = "username=admin&password=21232f297a57a5a743894a0e4a801fc3";
out.writeBytes(content);
out.flush();
out.close(); conn.connect();
StringBuffer sbf = new StringBuffer();
InputStream is = conn.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String strRead = null;
while ((strRead = reader.readLine()) != null) {
sbf.append(strRead);
sbf.append("\r\n");
}
reader.close();
System.out.println(sbf.toString());
}
}
运行如下:

2.2.2 携带token调用其它接口

其他接口调用时,附加token入参

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;public class RequestOtherAPIByToken {public static void main(String[] args) throws Exception {
URL url = new URL("http://localhost:10080/live/list");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
String content = "start=0&limit=10&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Mzc3NzExNTAsInB3IjoiMjEyMzJmMjk3YTU3YTVhNzQzODk0YTBlNGE4MDFmYzMiLCJ0bSI6MTUzNzY4NDc1MCwidW4iOiJhZG1pbiJ9.b1U-R-_HVKV9reWRD50327B1ztUqs3gowUGi_lDzlmU";
out.writeBytes(content);
out.flush();
out.close(); conn.connect();
StringBuffer sbf = new StringBuffer();
InputStream is = conn.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String strRead = null;
while ((strRead = reader.readLine()) != null) {
sbf.append(strRead);
sbf.append("\r\n");
}
reader.close();
System.out.println(sbf.toString());
}
}
运行如下

关于EasyDSS

EasyDSS(http://www.easydss.com)流媒体解决方案采用业界优秀的流媒体框架模式设计,服务运行轻量、高效、稳定、可靠、易维护,支持RTMP直播、RTMP推送、HTTP点播、HTTP-FLV直播、HLS直播,并支持关键帧缓冲,画面秒开等多种特性,能够接入Web、Android、iOS、H5、微信等全平台客户端,是移动互联网时代贴近企业点播/直播需求的一款接地气的流媒体服务器,配套OBS、EasyRTMP等直播推流工具以及EasyPlayer等网络播放器,可以形成一套完整的视频直播、录播解决方案,满足用户在各种行业场景的流媒体业务需求。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,564
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,412
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,185
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905