Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2015-04-22 09:01:38 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
aabe84046c9f93bcd75b6ec862561407290903d8
aabe8404
1 parent
4e5ddb51
refine hls ingester, quit when error.
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
19 行增加
和
28 行删除
trunk/src/main/srs_main_ingest_hls.cpp
trunk/src/main/srs_main_ingest_hls.cpp
查看文件 @
aabe840
...
...
@@ -48,9 +48,6 @@ using namespace std;
#include <srs_rtmp_amf0.hpp>
#include <srs_raw_avc.hpp>
// the retry timeout in ms.
#define SRS_INGEST_HLS_ERROR_RETRY_MS 3000
// pre-declare
int
proxy_hls2rtmp
(
std
::
string
hls
,
std
::
string
rtmp
);
...
...
@@ -217,7 +214,7 @@ private:
/**
* fetch all ts body.
*/
virtual
void
fetch_all_ts
(
bool
fresh_m3u8
);
virtual
int
fetch_all_ts
(
bool
fresh_m3u8
);
/**
* remove all ts which is dirty.
*/
...
...
@@ -245,7 +242,10 @@ int SrsIngestSrsInput::connect()
}
// fetch all ts.
fetch_all_ts
(
fresh_m3u8
);
if
((
ret
=
fetch_all_ts
(
fresh_m3u8
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"fetch all ts failed. ret=%d"
,
ret
);
return
ret
;
}
// remove all dirty ts.
remove_dirty
();
...
...
@@ -304,14 +304,8 @@ int SrsIngestSrsInput::parseTs(ISrsTsHandler* handler, char* body, int nb_body)
// process each ts packet
if
((
ret
=
context
->
decode
(
stream
,
handler
))
!=
ERROR_SUCCESS
)
{
// when peer closed, must interrupt parse and reconnect.
if
(
srs_is_client_gracefully_close
(
ret
))
{
srs_warn
(
"interrupt parse for peer closed. ret=%d"
,
ret
);
return
ret
;
}
srs_warn
(
"mpegts: ignore parse ts packet failed. ret=%d"
,
ret
);
continue
;
srs_error
(
"mpegts: ignore parse ts packet failed. ret=%d"
,
ret
);
return
ret
;
}
srs_info
(
"mpegts: parse ts packet completed"
);
}
...
...
@@ -536,7 +530,7 @@ void SrsIngestSrsInput::dirty_all_ts()
}
}
void
SrsIngestSrsInput
::
fetch_all_ts
(
bool
fresh_m3u8
)
int
SrsIngestSrsInput
::
fetch_all_ts
(
bool
fresh_m3u8
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -555,9 +549,9 @@ void SrsIngestSrsInput::fetch_all_ts(bool fresh_m3u8)
}
if
((
ret
=
tp
->
fetch
(
in_hls
->
get_url
()))
!=
ERROR_SUCCESS
)
{
srs_
warn
(
"ignore
ts %s for error. ret=%d"
,
tp
->
url
.
c_str
(),
ret
);
srs_
error
(
"fetch
ts %s for error. ret=%d"
,
tp
->
url
.
c_str
(),
ret
);
tp
->
skip
=
true
;
continue
;
return
ret
;
}
// only wait for a duration of last piece.
...
...
@@ -565,6 +559,8 @@ void SrsIngestSrsInput::fetch_all_ts(bool fresh_m3u8)
next_connect_time
=
srs_update_system_time_ms
()
+
(
int
)
tp
->
duration
*
1000
;
}
}
return
ret
;
}
...
...
@@ -779,10 +775,6 @@ int SrsIngestSrsOutput::on_ts_message(SrsTsMessage* msg)
// we must use queue to cache the msg, then parse it if possible.
queue
.
insert
(
std
::
make_pair
(
msg
->
dts
,
msg
->
detach
()));
if
((
ret
=
parse_message_queue
())
!=
ERROR_SUCCESS
)
{
// when peer closed, close the output and reconnect.
if
(
srs_is_client_gracefully_close
(
ret
))
{
close
();
}
return
ret
;
}
...
...
@@ -1204,6 +1196,7 @@ int SrsIngestSrsOutput::rtmp_write_packet(char type, u_int32_t timestamp, char*
// send out encoded msg.
if
((
ret
=
client
->
send_and_free_message
(
msg
,
stream_id
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"send RTMP type=%d, dts=%d, size=%d failed. ret=%d"
,
type
,
timestamp
,
size
,
ret
);
return
ret
;
}
...
...
@@ -1355,22 +1348,22 @@ public:
int
ret
=
ERROR_SUCCESS
;
if
((
ret
=
ic
->
connect
())
!=
ERROR_SUCCESS
)
{
srs_
warn
(
"connect oc failed. ret=%d"
,
ret
);
srs_
error
(
"connect oc failed. ret=%d"
,
ret
);
return
ret
;
}
if
((
ret
=
oc
->
connect
())
!=
ERROR_SUCCESS
)
{
srs_
warn
(
"connect ic failed. ret=%d"
,
ret
);
srs_
error
(
"connect ic failed. ret=%d"
,
ret
);
return
ret
;
}
if
((
ret
=
ic
->
parse
(
oc
,
oc
))
!=
ERROR_SUCCESS
)
{
srs_
warn
(
"proxy ts to rtmp failed. ret=%d"
,
ret
);
srs_
error
(
"proxy ts to rtmp failed. ret=%d"
,
ret
);
return
ret
;
}
if
((
ret
=
oc
->
flush_message_queue
())
!=
ERROR_SUCCESS
)
{
srs_
warn
(
"flush oc message failed. ret=%d"
,
ret
);
srs_
error
(
"flush oc message failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
@@ -1401,11 +1394,9 @@ int proxy_hls2rtmp(string hls, string rtmp)
SrsIngestSrsContext
context
(
&
hls_uri
,
&
rtmp_uri
);
for
(;;)
{
if
((
ret
=
context
.
proxy
())
==
ERROR_SUCCESS
)
{
continue
;
srs_error
(
"proxy hls to rtmp failed. ret=%d"
,
ret
);
return
ret
;
}
srs_warn
(
"proxy hls to rtmp failed. ret=%d"
,
ret
);
st_usleep
(
SRS_INGEST_HLS_ERROR_RETRY_MS
*
1000
);
}
return
ret
;
...
...
请
注册
或
登录
后发表评论