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
2014-06-29 17:17:50 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a888e52df150f61f82431dcf21a7d3624f63d8b5
a888e52d
1 parent
1eee4d25
donot mix the read and write for librtmp
隐藏空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
52 行增加
和
10 行删除
trunk/research/librtmp/srs_flv_injecter.c
trunk/research/librtmp/srs_flv_parser.c
trunk/research/librtmp/srs_ingest_flv.c
trunk/src/kernel/srs_kernel_error.hpp
trunk/src/kernel/srs_kernel_flv.cpp
trunk/src/kernel/srs_kernel_flv.hpp
trunk/src/libs/srs_librtmp.cpp
trunk/src/libs/srs_librtmp.hpp
trunk/research/librtmp/srs_flv_injecter.c
查看文件 @
a888e52
...
...
@@ -121,14 +121,14 @@ int process(const char* in_flv_file, const char* out_flv_file, srs_flv_t* pic, s
srs_amf0_t
amf0_data
=
NULL
;
srs_amf0_t
filepositions
=
NULL
;
if
((
ic
=
srs_flv_open
(
in_flv_file
))
==
NULL
)
{
if
((
ic
=
srs_flv_open
_read
(
in_flv_file
))
==
NULL
)
{
ret
=
2
;
trace
(
"open input flv file failed. ret=%d"
,
ret
);
return
ret
;
}
*
pic
=
ic
;
if
((
oc
=
srs_flv_open
(
out_flv_file
))
==
NULL
)
{
if
((
oc
=
srs_flv_open
_write
(
out_flv_file
))
==
NULL
)
{
ret
=
2
;
trace
(
"open output flv file failed. ret=%d"
,
ret
);
return
ret
;
...
...
trunk/research/librtmp/srs_flv_parser.c
查看文件 @
a888e52
...
...
@@ -64,7 +64,7 @@ int main(int argc, char** argv)
trace
(
"version: %d.%d.%d"
,
srs_version_major
(),
srs_version_minor
(),
srs_version_revision
());
trace
(
"input: %s"
,
in_flv_file
);
if
((
flv
=
srs_flv_open
(
in_flv_file
))
==
NULL
)
{
if
((
flv
=
srs_flv_open
_read
(
in_flv_file
))
==
NULL
)
{
ret
=
2
;
trace
(
"open flv file failed. ret=%d"
,
ret
);
return
ret
;
...
...
trunk/research/librtmp/srs_ingest_flv.c
查看文件 @
a888e52
...
...
@@ -93,7 +93,7 @@ int main(int argc, char** argv)
trace
(
"input: %s"
,
in_flv_file
);
trace
(
"output: %s"
,
out_rtmp_url
);
if
((
flv
=
srs_flv_open
(
in_flv_file
))
==
NULL
)
{
if
((
flv
=
srs_flv_open
_read
(
in_flv_file
))
==
NULL
)
{
ret
=
2
;
trace
(
"open flv file failed. ret=%d"
,
ret
);
return
ret
;
...
...
trunk/src/kernel/srs_kernel_error.hpp
查看文件 @
a888e52
...
...
@@ -120,6 +120,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_SYSTEM_CREATE_PIPE 430
#define ERROR_SYSTEM_FILE_SEEK 431
#define ERROR_SYSTEM_FLV_HEADER 432
#define ERROR_SYSTEM_IO_INVALID 433
// see librtmp.
// failed when open ssl create the dh
...
...
trunk/src/kernel/srs_kernel_flv.cpp
查看文件 @
a888e52
...
...
@@ -165,6 +165,11 @@ void SrsFileReader::close()
return
;
}
bool
SrsFileReader
::
is_open
()
{
return
fd
>
0
;
}
int64_t
SrsFileReader
::
tellg
()
{
return
(
int64_t
)
::
lseek
(
fd
,
0
,
SEEK_CUR
);
...
...
trunk/src/kernel/srs_kernel_flv.hpp
查看文件 @
a888e52
...
...
@@ -69,6 +69,7 @@ public:
virtual
int
open
(
std
::
string
file
);
virtual
void
close
();
public
:
virtual
bool
is_open
();
virtual
int64_t
tellg
();
virtual
void
skip
(
int64_t
size
);
virtual
int64_t
lseek
(
int64_t
offset
);
...
...
trunk/src/libs/srs_librtmp.cpp
查看文件 @
a888e52
...
...
@@ -467,28 +467,37 @@ struct FlvContext
SrsFlvDecoder
dec
;
};
srs_flv_t
srs_flv_open
(
const
char
*
file
)
srs_flv_t
srs_flv_open
_read
(
const
char
*
file
)
{
int
ret
=
ERROR_SUCCESS
;
FlvContext
*
flv
=
new
FlvContext
();
if
((
ret
=
flv
->
writ
er
.
open
(
file
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
flv
->
read
er
.
open
(
file
))
!=
ERROR_SUCCESS
)
{
srs_freep
(
flv
);
return
NULL
;
}
if
((
ret
=
flv
->
enc
.
initialize
(
&
flv
->
writ
er
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
flv
->
dec
.
initialize
(
&
flv
->
read
er
))
!=
ERROR_SUCCESS
)
{
srs_freep
(
flv
);
return
NULL
;
}
if
((
ret
=
flv
->
reader
.
open
(
file
))
!=
ERROR_SUCCESS
)
{
return
flv
;
}
srs_flv_t
srs_flv_open_write
(
const
char
*
file
)
{
int
ret
=
ERROR_SUCCESS
;
FlvContext
*
flv
=
new
FlvContext
();
if
((
ret
=
flv
->
writer
.
open
(
file
))
!=
ERROR_SUCCESS
)
{
srs_freep
(
flv
);
return
NULL
;
}
if
((
ret
=
flv
->
dec
.
initialize
(
&
flv
->
read
er
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
flv
->
enc
.
initialize
(
&
flv
->
writ
er
))
!=
ERROR_SUCCESS
)
{
srs_freep
(
flv
);
return
NULL
;
}
...
...
@@ -507,6 +516,11 @@ int srs_flv_read_header(srs_flv_t flv, char header[9])
int
ret
=
ERROR_SUCCESS
;
FlvContext
*
context
=
(
FlvContext
*
)
flv
;
if
(
!
context
->
reader
.
is_open
())
{
return
ERROR_SYSTEM_IO_INVALID
;
}
if
((
ret
=
context
->
dec
.
read_header
(
header
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
...
...
@@ -524,6 +538,11 @@ int srs_flv_read_tag_header(srs_flv_t flv, char* ptype, int32_t* pdata_size, u_i
int
ret
=
ERROR_SUCCESS
;
FlvContext
*
context
=
(
FlvContext
*
)
flv
;
if
(
!
context
->
reader
.
is_open
())
{
return
ERROR_SYSTEM_IO_INVALID
;
}
if
((
ret
=
context
->
dec
.
read_tag_header
(
ptype
,
pdata_size
,
ptime
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
...
...
@@ -536,6 +555,11 @@ int srs_flv_read_tag_data(srs_flv_t flv, char* data, int32_t size)
int
ret
=
ERROR_SUCCESS
;
FlvContext
*
context
=
(
FlvContext
*
)
flv
;
if
(
!
context
->
reader
.
is_open
())
{
return
ERROR_SYSTEM_IO_INVALID
;
}
if
((
ret
=
context
->
dec
.
read_tag_data
(
data
,
size
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
...
...
@@ -553,6 +577,11 @@ int srs_flv_write_header(srs_flv_t flv, char header[9])
int
ret
=
ERROR_SUCCESS
;
FlvContext
*
context
=
(
FlvContext
*
)
flv
;
if
(
!
context
->
writer
.
is_open
())
{
return
ERROR_SYSTEM_IO_INVALID
;
}
if
((
ret
=
context
->
enc
.
write_header
(
header
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
...
...
@@ -565,6 +594,11 @@ int srs_flv_write_tag(srs_flv_t flv, char type, int32_t time, char* data, int si
int
ret
=
ERROR_SUCCESS
;
FlvContext
*
context
=
(
FlvContext
*
)
flv
;
if
(
!
context
->
writer
.
is_open
())
{
return
ERROR_SYSTEM_IO_INVALID
;
}
if
(
type
==
SRS_RTMP_TYPE_AUDIO
)
{
return
context
->
enc
.
write_audio
(
time
,
data
,
size
);
}
else
if
(
type
==
SRS_RTMP_TYPE_VIDEO
)
{
...
...
trunk/src/libs/srs_librtmp.hpp
查看文件 @
a888e52
...
...
@@ -166,7 +166,8 @@ int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp);
typedef
void
*
srs_flv_t
;
typedef
int
flv_bool
;
/* open flv file for both read/write. */
srs_flv_t
srs_flv_open
(
const
char
*
file
);
srs_flv_t
srs_flv_open_read
(
const
char
*
file
);
srs_flv_t
srs_flv_open_write
(
const
char
*
file
);
void
srs_flv_close
(
srs_flv_t
flv
);
/* read the flv header. 9bytes header. drop the 4bytes zero previous tag size */
int
srs_flv_read_header
(
srs_flv_t
flv
,
char
header
[
9
]);
...
...
请
注册
或
登录
后发表评论