Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
64d90c28
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
64d90c28
编写于
5月 31, 2019
作者:
R
Roman Sivriver
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rtmp-services: Add YouNow service and implement ingest lookup
上级
b98ea73c
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
150 addition
and
1 deletion
+150
-1
plugins/rtmp-services/CMakeLists.txt
plugins/rtmp-services/CMakeLists.txt
+9
-1
plugins/rtmp-services/data/services.json
plugins/rtmp-services/data/services.json
+18
-0
plugins/rtmp-services/rtmp-common.c
plugins/rtmp-services/rtmp-common.c
+7
-0
plugins/rtmp-services/younow.c
plugins/rtmp-services/younow.c
+113
-0
plugins/rtmp-services/younow.h
plugins/rtmp-services/younow.h
+3
-0
未找到文件。
plugins/rtmp-services/CMakeLists.txt
浏览文件 @
64d90c28
project
(
rtmp-services
)
project
(
rtmp-services
)
find_package
(
Libcurl REQUIRED
)
include_directories
(
${
LIBCURL_INCLUDE_DIRS
}
)
include_directories
(
${
OBS_JANSSON_INCLUDE_DIRS
}
)
include_directories
(
${
OBS_JANSSON_INCLUDE_DIRS
}
)
set
(
rtmp-services_SOURCES
set
(
rtmp-services_SOURCES
twitch.c
twitch.c
younow.c
rtmp-common.c
rtmp-common.c
rtmp-custom.c
rtmp-custom.c
rtmp-services-main.c
)
rtmp-services-main.c
)
set
(
rtmp-services_HEADERS
set
(
rtmp-services_HEADERS
twitch.h
twitch.h
younow.h
rtmp-format-ver.h
)
rtmp-format-ver.h
)
set
(
RTMP_SERVICES_URL
set
(
RTMP_SERVICES_URL
...
@@ -28,10 +34,12 @@ add_library(rtmp-services MODULE
...
@@ -28,10 +34,12 @@ add_library(rtmp-services MODULE
${
rtmp-services_SOURCES
}
${
rtmp-services_SOURCES
}
${
rtmp-services_HEADERS
}
${
rtmp-services_HEADERS
}
${
rtmp-services_config_HEADERS
}
)
${
rtmp-services_config_HEADERS
}
)
target_link_libraries
(
rtmp-services
target_link_libraries
(
rtmp-services
libobs
libobs
file-updater
file-updater
${
OBS_JANSSON_IMPORT
}
)
${
OBS_JANSSON_IMPORT
}
${
LIBCURL_LIBRARIES
}
)
target_include_directories
(
rtmp-services
target_include_directories
(
rtmp-services
PUBLIC
PUBLIC
...
...
plugins/rtmp-services/data/services.json
浏览文件 @
64d90c28
...
@@ -1514,6 +1514,24 @@
...
@@ -1514,6 +1514,24 @@
"x264opts"
:
"tune=zerolatency"
"x264opts"
:
"tune=zerolatency"
}
}
},
},
{
"name"
:
"YouNow"
,
"common"
:
false
,
"servers"
:
[
{
"name"
:
"younow.com"
,
"url"
:
"https://signaling-api.younow-prod.video.propsproject.com/api/v1/ingest/server/"
}
],
"recommended"
:
{
"keyint"
:
2
,
"output"
:
"ftl_output"
,
"max audio bitrate"
:
160
,
"max video bitrate"
:
7000
,
"profile"
:
"main"
,
"bframes"
:
0
}
},
{
{
"name"
:
"Steam"
,
"name"
:
"Steam"
,
"common"
:
false
,
"common"
:
false
,
...
...
plugins/rtmp-services/rtmp-common.c
浏览文件 @
64d90c28
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include "rtmp-format-ver.h"
#include "rtmp-format-ver.h"
#include "twitch.h"
#include "twitch.h"
#include "younow.h"
struct
rtmp_common
{
struct
rtmp_common
{
char
*
service
;
char
*
service
;
...
@@ -594,6 +595,12 @@ static const char *rtmp_common_url(void *data)
...
@@ -594,6 +595,12 @@ static const char *rtmp_common_url(void *data)
}
}
}
}
if
(
service
->
service
&&
strcmp
(
service
->
service
,
"YouNow"
)
==
0
)
{
if
(
service
->
server
&&
service
->
key
)
{
return
younow_get_ingest
(
service
->
server
,
service
->
key
);
}
}
return
service
->
server
;
return
service
->
server
;
}
}
...
...
plugins/rtmp-services/younow.c
0 → 100644
浏览文件 @
64d90c28
#include <curl/curl.h>
#include <stdlib.h>
#include <string.h>
#include <util/dstr.h>
#include "util/base.h"
#include "younow.h"
struct
younow_mem_struct
{
char
*
memory
;
size_t
size
;
};
static
char
*
current_ingest
=
NULL
;
static
size_t
younow_write_cb
(
void
*
contents
,
size_t
size
,
size_t
nmemb
,
void
*
userp
)
{
size_t
realsize
=
size
*
nmemb
;
struct
younow_mem_struct
*
mem
=
(
struct
younow_mem_struct
*
)
userp
;
mem
->
memory
=
realloc
(
mem
->
memory
,
mem
->
size
+
realsize
+
1
);
if
(
mem
->
memory
==
NULL
)
{
blog
(
LOG_WARNING
,
"yyounow_write_cb: realloc returned NULL"
);
return
0
;
}
memcpy
(
&
(
mem
->
memory
[
mem
->
size
]),
contents
,
realsize
);
mem
->
size
+=
realsize
;
mem
->
memory
[
mem
->
size
]
=
0
;
return
realsize
;
}
const
char
*
younow_get_ingest
(
const
char
*
server
,
const
char
*
key
)
{
CURL
*
curl_handle
;
CURLcode
res
;
struct
younow_mem_struct
chunk
;
struct
dstr
uri
;
long
response_code
;
// find the delimiter in stream key
const
char
*
delim
=
strchr
(
key
,
'_'
);
if
(
delim
==
NULL
)
{
blog
(
LOG_WARNING
,
"younow_get_ingest: delimiter not found in stream key"
);
return
server
;
}
curl_handle
=
curl_easy_init
();
chunk
.
memory
=
malloc
(
1
);
/* will be grown as needed by realloc */
chunk
.
size
=
0
;
/* no data at this point */
dstr_init
(
&
uri
);
dstr_copy
(
&
uri
,
server
);
dstr_ncat
(
&
uri
,
key
,
delim
-
key
);
curl_easy_setopt
(
curl_handle
,
CURLOPT_URL
,
uri
.
array
);
curl_easy_setopt
(
curl_handle
,
CURLOPT_SSL_VERIFYPEER
,
true
);
curl_easy_setopt
(
curl_handle
,
CURLOPT_SSL_VERIFYHOST
,
2L
);
curl_easy_setopt
(
curl_handle
,
CURLOPT_TIMEOUT
,
3L
);
curl_easy_setopt
(
curl_handle
,
CURLOPT_WRITEFUNCTION
,
younow_write_cb
);
curl_easy_setopt
(
curl_handle
,
CURLOPT_WRITEDATA
,
(
void
*
)
&
chunk
);
#if LIBCURL_VERSION_NUM >= 0x072400
// A lot of servers don't yet support ALPN
curl_easy_setopt
(
curl_handle
,
CURLOPT_SSL_ENABLE_ALPN
,
0
);
#endif
res
=
curl_easy_perform
(
curl_handle
);
dstr_free
(
&
uri
);
if
(
res
!=
CURLE_OK
)
{
blog
(
LOG_WARNING
,
"younow_get_ingest: curl_easy_perform() failed: %s"
,
curl_easy_strerror
(
res
));
curl_easy_cleanup
(
curl_handle
);
free
(
chunk
.
memory
);
return
server
;
}
curl_easy_getinfo
(
curl_handle
,
CURLINFO_RESPONSE_CODE
,
&
response_code
);
if
(
response_code
!=
200
)
{
blog
(
LOG_WARNING
,
"younow_get_ingest: curl_easy_perform() returned code: %ld"
,
response_code
);
curl_easy_cleanup
(
curl_handle
);
free
(
chunk
.
memory
);
return
server
;
}
curl_easy_cleanup
(
curl_handle
);
if
(
chunk
.
size
==
0
)
{
blog
(
LOG_WARNING
,
"younow_get_ingest: curl_easy_perform() returned empty response"
);
free
(
chunk
.
memory
);
return
server
;
}
if
(
current_ingest
)
{
free
(
current_ingest
);
current_ingest
=
NULL
;
}
current_ingest
=
strdup
(
chunk
.
memory
);
free
(
chunk
.
memory
);
blog
(
LOG_INFO
,
"younow_get_ingest: returning ingest: %s"
,
current_ingest
);
return
current_ingest
;
}
plugins/rtmp-services/younow.h
0 → 100644
浏览文件 @
64d90c28
#pragma once
extern
const
char
*
younow_get_ingest
(
const
char
*
server
,
const
char
*
key
);
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录