Skip to content

Commit

Permalink
for #738, implements boxes codec
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Feb 1, 2017
1 parent b6bb3f2 commit 2ad265b
Show file tree
Hide file tree
Showing 6 changed files with 1,885 additions and 82 deletions.
1 change: 1 addition & 0 deletions trunk/src/kernel/srs_kernel_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class ISrsCodec
/**
* get the number of bytes to code to.
*/
// TODO: FIXME: change to uint64_t.
virtual int nb_bytes() = 0;
/**
* encode object to bytes in SrsBuffer.
Expand Down
5 changes: 5 additions & 0 deletions trunk/src/kernel/srs_kernel_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_REQUEST_DATA 3066
#define ERROR_EDGE_PORT_INVALID 3067
#define ERROR_EXPECT_FILE_IO 3068
#define ERROR_MP4_BOX_OVERFLOW 3069
#define ERROR_MP4_BOX_REQUIRE_SPACE 3070
#define ERROR_MP4_BOX_ILLEGAL_TYPE 3071
#define ERROR_MP4_BOX_ILLEGAL_SCHEMA 3072
#define ERROR_MP4_BOX_STRING 3073

///////////////////////////////////////////////////////
// HTTP/StreamCaster/KAFKA protocol error.
Expand Down
4 changes: 4 additions & 0 deletions trunk/src/kernel/srs_kernel_flv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ int SrsFlvDecoder::read_header(char header[9])

srs_assert(header);

// TODO: FIXME: Should use readfully.
if ((ret = reader->read(header, 9, NULL)) != ERROR_SUCCESS) {
return ret;
}
Expand All @@ -746,6 +747,7 @@ int SrsFlvDecoder::read_tag_header(char* ptype, int32_t* pdata_size, uint32_t* p
char th[11]; // tag header

// read tag header
// TODO: FIXME: Should use readfully.
if ((ret = reader->read(th, 11, NULL)) != ERROR_SUCCESS) {
if (ret != ERROR_SYSTEM_FILE_EOF) {
srs_error("read flv tag header failed. ret=%d", ret);
Expand Down Expand Up @@ -783,6 +785,7 @@ int SrsFlvDecoder::read_tag_data(char* data, int32_t size)

srs_assert(data);

// TODO: FIXME: Should use readfully.
if ((ret = reader->read(data, size, NULL)) != ERROR_SUCCESS) {
if (ret != ERROR_SYSTEM_FILE_EOF) {
srs_error("read flv tag header failed. ret=%d", ret);
Expand All @@ -801,6 +804,7 @@ int SrsFlvDecoder::read_previous_tag_size(char previous_tag_size[4])
srs_assert(previous_tag_size);

// ignore 4bytes tag size.
// TODO: FIXME: Should use readfully.
if ((ret = reader->read(previous_tag_size, 4, NULL)) != ERROR_SUCCESS) {
if (ret != ERROR_SYSTEM_FILE_EOF) {
srs_error("read flv previous tag size failed. ret=%d", ret);
Expand Down
4 changes: 4 additions & 0 deletions trunk/src/kernel/srs_kernel_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class ISrsReader
ISrsReader();
virtual ~ISrsReader();
public:
/**
* Read bytes from reader.
* @param nread How many bytes read from channel. NULL to ignore.
*/
virtual int read(void* buf, size_t size, ssize_t* nread) = 0;
};

Expand Down
Loading

0 comments on commit 2ad265b

Please sign in to comment.