mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
adjust the api, move audio and h264 after rtmp
This commit is contained in:
parent
aa69f6197a
commit
2a9bec3d89
2 changed files with 549 additions and 549 deletions
|
@ -262,164 +262,6 @@ extern int srs_rtmp_write_packet(srs_rtmp_t rtmp,
|
|||
char type, u_int32_t timestamp, char* data, int size
|
||||
);
|
||||
|
||||
/*************************************************************
|
||||
**************************************************************
|
||||
* flv codec
|
||||
* @example /trunk/research/librtmp/srs_flv_injecter.c
|
||||
* @example /trunk/research/librtmp/srs_flv_parser.c
|
||||
* @example /trunk/research/librtmp/srs_ingest_flv.c
|
||||
* @example /trunk/research/librtmp/srs_ingest_rtmp.c
|
||||
**************************************************************
|
||||
*************************************************************/
|
||||
typedef void* srs_flv_t;
|
||||
typedef int srs_flv_bool;
|
||||
/* open flv file for both read/write. */
|
||||
extern srs_flv_t srs_flv_open_read(const char* file);
|
||||
extern srs_flv_t srs_flv_open_write(const char* file);
|
||||
extern void srs_flv_close(srs_flv_t flv);
|
||||
/**
|
||||
* read the flv header. 9bytes header.
|
||||
* @param header, @see E.2 The FLV header, flv_v10_1.pdf in SRS doc.
|
||||
* 3bytes, signature, "FLV",
|
||||
* 1bytes, version, 0x01,
|
||||
* 1bytes, flags, UB[5] 0, UB[1] audio present, UB[1] 0, UB[1] video present.
|
||||
* 4bytes, dataoffset, 0x09, The length of this header in bytes
|
||||
*
|
||||
* @return 0, success; otherswise, failed.
|
||||
* @remark, drop the 4bytes zero previous tag size.
|
||||
*/
|
||||
extern int srs_flv_read_header(srs_flv_t flv, char header[9]);
|
||||
/**
|
||||
* read the flv tag header, 1bytes tag, 3bytes data_size,
|
||||
* 4bytes time, 3bytes stream id.
|
||||
* @param ptype, output the type of tag, macros:
|
||||
* SRS_RTMP_TYPE_AUDIO, FlvTagAudio
|
||||
* SRS_RTMP_TYPE_VIDEO, FlvTagVideo
|
||||
* SRS_RTMP_TYPE_SCRIPT, FlvTagScript
|
||||
* @param pdata_size, output the size of tag data.
|
||||
* @param ptime, output the time of tag, the dts in ms.
|
||||
*
|
||||
* @return 0, success; otherswise, failed.
|
||||
* @remark, user must ensure the next is a tag, srs never check it.
|
||||
*/
|
||||
extern int srs_flv_read_tag_header(srs_flv_t flv,
|
||||
char* ptype, int32_t* pdata_size, u_int32_t* ptime
|
||||
);
|
||||
/**
|
||||
* read the tag data. drop the 4bytes previous tag size
|
||||
* @param data, the data to read, user alloc and free it.
|
||||
* @param size, the size of data to read, get by srs_flv_read_tag_header().
|
||||
* @remark, srs will ignore and drop the 4bytes previous tag size.
|
||||
*/
|
||||
extern int srs_flv_read_tag_data(srs_flv_t flv, char* data, int32_t size);
|
||||
/**
|
||||
* write the flv header. 9bytes header.
|
||||
* @param header, @see E.2 The FLV header, flv_v10_1.pdf in SRS doc.
|
||||
* 3bytes, signature, "FLV",
|
||||
* 1bytes, version, 0x01,
|
||||
* 1bytes, flags, UB[5] 0, UB[1] audio present, UB[1] 0, UB[1] video present.
|
||||
* 4bytes, dataoffset, 0x09, The length of this header in bytes
|
||||
*
|
||||
* @return 0, success; otherswise, failed.
|
||||
* @remark, auto write the 4bytes zero previous tag size.
|
||||
*/
|
||||
extern int srs_flv_write_header(srs_flv_t flv, char header[9]);
|
||||
/**
|
||||
* write the flv tag to file.
|
||||
*
|
||||
* @return 0, success; otherswise, failed.
|
||||
* @remark, auto write the 4bytes zero previous tag size.
|
||||
*/
|
||||
/* write flv tag to file, auto write the 4bytes previous tag size */
|
||||
extern int srs_flv_write_tag(srs_flv_t flv,
|
||||
char type, int32_t time, char* data, int size
|
||||
);
|
||||
/**
|
||||
* get the tag size, for flv injecter to adjust offset,
|
||||
* size = tag_header(11B) + data_size + previous_tag(4B)
|
||||
* @return the size of tag.
|
||||
*/
|
||||
extern int srs_flv_size_tag(int data_size);
|
||||
/* file stream */
|
||||
/* file stream tellg to get offset */
|
||||
extern int64_t srs_flv_tellg(srs_flv_t flv);
|
||||
/* seek file stream, offset is form the start of file */
|
||||
extern void srs_flv_lseek(srs_flv_t flv, int64_t offset);
|
||||
/* error code */
|
||||
/* whether the error code indicates EOF */
|
||||
extern srs_flv_bool srs_flv_is_eof(int error_code);
|
||||
/* media codec */
|
||||
/**
|
||||
* whether the video body is sequence header
|
||||
* @param data, the data of tag, read by srs_flv_read_tag_data().
|
||||
* @param size, the size of tag, read by srs_flv_read_tag_data().
|
||||
*/
|
||||
extern srs_flv_bool srs_flv_is_sequence_header(char* data, int32_t size);
|
||||
/**
|
||||
* whether the video body is keyframe
|
||||
* @param data, the data of tag, read by srs_flv_read_tag_data().
|
||||
* @param size, the size of tag, read by srs_flv_read_tag_data().
|
||||
*/
|
||||
extern srs_flv_bool srs_flv_is_keyframe(char* data, int32_t size);
|
||||
|
||||
/*************************************************************
|
||||
**************************************************************
|
||||
* amf0 codec
|
||||
* @example /trunk/research/librtmp/srs_ingest_flv.c
|
||||
* @example /trunk/research/librtmp/srs_ingest_rtmp.c
|
||||
**************************************************************
|
||||
*************************************************************/
|
||||
/* the output handler. */
|
||||
typedef void* srs_amf0_t;
|
||||
typedef int srs_amf0_bool;
|
||||
typedef double srs_amf0_number;
|
||||
/**
|
||||
* parse amf0 from data.
|
||||
* @param nparsed, the parsed size, NULL to ignore.
|
||||
* @return the parsed amf0 object. NULL for error.
|
||||
*/
|
||||
extern srs_amf0_t srs_amf0_parse(char* data, int size, int* nparsed);
|
||||
extern srs_amf0_t srs_amf0_create_number(srs_amf0_number value);
|
||||
extern srs_amf0_t srs_amf0_create_ecma_array();
|
||||
extern srs_amf0_t srs_amf0_create_strict_array();
|
||||
extern srs_amf0_t srs_amf0_create_object();
|
||||
extern void srs_amf0_free(srs_amf0_t amf0);
|
||||
extern void srs_amf0_free_bytes(char* data);
|
||||
/* size and to bytes */
|
||||
extern int srs_amf0_size(srs_amf0_t amf0);
|
||||
extern int srs_amf0_serialize(srs_amf0_t amf0, char* data, int size);
|
||||
/* type detecter */
|
||||
extern srs_amf0_bool srs_amf0_is_string(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_is_boolean(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_is_number(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_is_null(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_is_object(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_is_ecma_array(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_is_strict_array(srs_amf0_t amf0);
|
||||
/* value converter */
|
||||
extern const char* srs_amf0_to_string(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_to_boolean(srs_amf0_t amf0);
|
||||
extern srs_amf0_number srs_amf0_to_number(srs_amf0_t amf0);
|
||||
/* value setter */
|
||||
extern void srs_amf0_set_number(srs_amf0_t amf0, srs_amf0_number value);
|
||||
/* object value converter */
|
||||
extern int srs_amf0_object_property_count(srs_amf0_t amf0);
|
||||
extern const char* srs_amf0_object_property_name_at(srs_amf0_t amf0, int index);
|
||||
extern srs_amf0_t srs_amf0_object_property_value_at(srs_amf0_t amf0, int index);
|
||||
extern srs_amf0_t srs_amf0_object_property(srs_amf0_t amf0, const char* name);
|
||||
extern void srs_amf0_object_property_set(srs_amf0_t amf0, const char* name, srs_amf0_t value);
|
||||
extern void srs_amf0_object_clear(srs_amf0_t amf0);
|
||||
/* ecma array value converter */
|
||||
extern int srs_amf0_ecma_array_property_count(srs_amf0_t amf0);
|
||||
extern const char* srs_amf0_ecma_array_property_name_at(srs_amf0_t amf0, int index);
|
||||
extern srs_amf0_t srs_amf0_ecma_array_property_value_at(srs_amf0_t amf0, int index);
|
||||
extern srs_amf0_t srs_amf0_ecma_array_property(srs_amf0_t amf0, const char* name);
|
||||
extern void srs_amf0_ecma_array_property_set(srs_amf0_t amf0, const char* name, srs_amf0_t value);
|
||||
/* strict array value converter */
|
||||
extern int srs_amf0_strict_array_property_count(srs_amf0_t amf0);
|
||||
extern srs_amf0_t srs_amf0_strict_array_property_at(srs_amf0_t amf0, int index);
|
||||
extern void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value);
|
||||
|
||||
/*************************************************************
|
||||
**************************************************************
|
||||
* audio raw codec
|
||||
|
@ -583,6 +425,164 @@ extern int srs_h264_startswith_annexb(
|
|||
int* pnb_start_code
|
||||
);
|
||||
|
||||
/*************************************************************
|
||||
**************************************************************
|
||||
* flv codec
|
||||
* @example /trunk/research/librtmp/srs_flv_injecter.c
|
||||
* @example /trunk/research/librtmp/srs_flv_parser.c
|
||||
* @example /trunk/research/librtmp/srs_ingest_flv.c
|
||||
* @example /trunk/research/librtmp/srs_ingest_rtmp.c
|
||||
**************************************************************
|
||||
*************************************************************/
|
||||
typedef void* srs_flv_t;
|
||||
typedef int srs_flv_bool;
|
||||
/* open flv file for both read/write. */
|
||||
extern srs_flv_t srs_flv_open_read(const char* file);
|
||||
extern srs_flv_t srs_flv_open_write(const char* file);
|
||||
extern void srs_flv_close(srs_flv_t flv);
|
||||
/**
|
||||
* read the flv header. 9bytes header.
|
||||
* @param header, @see E.2 The FLV header, flv_v10_1.pdf in SRS doc.
|
||||
* 3bytes, signature, "FLV",
|
||||
* 1bytes, version, 0x01,
|
||||
* 1bytes, flags, UB[5] 0, UB[1] audio present, UB[1] 0, UB[1] video present.
|
||||
* 4bytes, dataoffset, 0x09, The length of this header in bytes
|
||||
*
|
||||
* @return 0, success; otherswise, failed.
|
||||
* @remark, drop the 4bytes zero previous tag size.
|
||||
*/
|
||||
extern int srs_flv_read_header(srs_flv_t flv, char header[9]);
|
||||
/**
|
||||
* read the flv tag header, 1bytes tag, 3bytes data_size,
|
||||
* 4bytes time, 3bytes stream id.
|
||||
* @param ptype, output the type of tag, macros:
|
||||
* SRS_RTMP_TYPE_AUDIO, FlvTagAudio
|
||||
* SRS_RTMP_TYPE_VIDEO, FlvTagVideo
|
||||
* SRS_RTMP_TYPE_SCRIPT, FlvTagScript
|
||||
* @param pdata_size, output the size of tag data.
|
||||
* @param ptime, output the time of tag, the dts in ms.
|
||||
*
|
||||
* @return 0, success; otherswise, failed.
|
||||
* @remark, user must ensure the next is a tag, srs never check it.
|
||||
*/
|
||||
extern int srs_flv_read_tag_header(srs_flv_t flv,
|
||||
char* ptype, int32_t* pdata_size, u_int32_t* ptime
|
||||
);
|
||||
/**
|
||||
* read the tag data. drop the 4bytes previous tag size
|
||||
* @param data, the data to read, user alloc and free it.
|
||||
* @param size, the size of data to read, get by srs_flv_read_tag_header().
|
||||
* @remark, srs will ignore and drop the 4bytes previous tag size.
|
||||
*/
|
||||
extern int srs_flv_read_tag_data(srs_flv_t flv, char* data, int32_t size);
|
||||
/**
|
||||
* write the flv header. 9bytes header.
|
||||
* @param header, @see E.2 The FLV header, flv_v10_1.pdf in SRS doc.
|
||||
* 3bytes, signature, "FLV",
|
||||
* 1bytes, version, 0x01,
|
||||
* 1bytes, flags, UB[5] 0, UB[1] audio present, UB[1] 0, UB[1] video present.
|
||||
* 4bytes, dataoffset, 0x09, The length of this header in bytes
|
||||
*
|
||||
* @return 0, success; otherswise, failed.
|
||||
* @remark, auto write the 4bytes zero previous tag size.
|
||||
*/
|
||||
extern int srs_flv_write_header(srs_flv_t flv, char header[9]);
|
||||
/**
|
||||
* write the flv tag to file.
|
||||
*
|
||||
* @return 0, success; otherswise, failed.
|
||||
* @remark, auto write the 4bytes zero previous tag size.
|
||||
*/
|
||||
/* write flv tag to file, auto write the 4bytes previous tag size */
|
||||
extern int srs_flv_write_tag(srs_flv_t flv,
|
||||
char type, int32_t time, char* data, int size
|
||||
);
|
||||
/**
|
||||
* get the tag size, for flv injecter to adjust offset,
|
||||
* size = tag_header(11B) + data_size + previous_tag(4B)
|
||||
* @return the size of tag.
|
||||
*/
|
||||
extern int srs_flv_size_tag(int data_size);
|
||||
/* file stream */
|
||||
/* file stream tellg to get offset */
|
||||
extern int64_t srs_flv_tellg(srs_flv_t flv);
|
||||
/* seek file stream, offset is form the start of file */
|
||||
extern void srs_flv_lseek(srs_flv_t flv, int64_t offset);
|
||||
/* error code */
|
||||
/* whether the error code indicates EOF */
|
||||
extern srs_flv_bool srs_flv_is_eof(int error_code);
|
||||
/* media codec */
|
||||
/**
|
||||
* whether the video body is sequence header
|
||||
* @param data, the data of tag, read by srs_flv_read_tag_data().
|
||||
* @param size, the size of tag, read by srs_flv_read_tag_data().
|
||||
*/
|
||||
extern srs_flv_bool srs_flv_is_sequence_header(char* data, int32_t size);
|
||||
/**
|
||||
* whether the video body is keyframe
|
||||
* @param data, the data of tag, read by srs_flv_read_tag_data().
|
||||
* @param size, the size of tag, read by srs_flv_read_tag_data().
|
||||
*/
|
||||
extern srs_flv_bool srs_flv_is_keyframe(char* data, int32_t size);
|
||||
|
||||
/*************************************************************
|
||||
**************************************************************
|
||||
* amf0 codec
|
||||
* @example /trunk/research/librtmp/srs_ingest_flv.c
|
||||
* @example /trunk/research/librtmp/srs_ingest_rtmp.c
|
||||
**************************************************************
|
||||
*************************************************************/
|
||||
/* the output handler. */
|
||||
typedef void* srs_amf0_t;
|
||||
typedef int srs_amf0_bool;
|
||||
typedef double srs_amf0_number;
|
||||
/**
|
||||
* parse amf0 from data.
|
||||
* @param nparsed, the parsed size, NULL to ignore.
|
||||
* @return the parsed amf0 object. NULL for error.
|
||||
*/
|
||||
extern srs_amf0_t srs_amf0_parse(char* data, int size, int* nparsed);
|
||||
extern srs_amf0_t srs_amf0_create_number(srs_amf0_number value);
|
||||
extern srs_amf0_t srs_amf0_create_ecma_array();
|
||||
extern srs_amf0_t srs_amf0_create_strict_array();
|
||||
extern srs_amf0_t srs_amf0_create_object();
|
||||
extern void srs_amf0_free(srs_amf0_t amf0);
|
||||
extern void srs_amf0_free_bytes(char* data);
|
||||
/* size and to bytes */
|
||||
extern int srs_amf0_size(srs_amf0_t amf0);
|
||||
extern int srs_amf0_serialize(srs_amf0_t amf0, char* data, int size);
|
||||
/* type detecter */
|
||||
extern srs_amf0_bool srs_amf0_is_string(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_is_boolean(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_is_number(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_is_null(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_is_object(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_is_ecma_array(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_is_strict_array(srs_amf0_t amf0);
|
||||
/* value converter */
|
||||
extern const char* srs_amf0_to_string(srs_amf0_t amf0);
|
||||
extern srs_amf0_bool srs_amf0_to_boolean(srs_amf0_t amf0);
|
||||
extern srs_amf0_number srs_amf0_to_number(srs_amf0_t amf0);
|
||||
/* value setter */
|
||||
extern void srs_amf0_set_number(srs_amf0_t amf0, srs_amf0_number value);
|
||||
/* object value converter */
|
||||
extern int srs_amf0_object_property_count(srs_amf0_t amf0);
|
||||
extern const char* srs_amf0_object_property_name_at(srs_amf0_t amf0, int index);
|
||||
extern srs_amf0_t srs_amf0_object_property_value_at(srs_amf0_t amf0, int index);
|
||||
extern srs_amf0_t srs_amf0_object_property(srs_amf0_t amf0, const char* name);
|
||||
extern void srs_amf0_object_property_set(srs_amf0_t amf0, const char* name, srs_amf0_t value);
|
||||
extern void srs_amf0_object_clear(srs_amf0_t amf0);
|
||||
/* ecma array value converter */
|
||||
extern int srs_amf0_ecma_array_property_count(srs_amf0_t amf0);
|
||||
extern const char* srs_amf0_ecma_array_property_name_at(srs_amf0_t amf0, int index);
|
||||
extern srs_amf0_t srs_amf0_ecma_array_property_value_at(srs_amf0_t amf0, int index);
|
||||
extern srs_amf0_t srs_amf0_ecma_array_property(srs_amf0_t amf0, const char* name);
|
||||
extern void srs_amf0_ecma_array_property_set(srs_amf0_t amf0, const char* name, srs_amf0_t value);
|
||||
/* strict array value converter */
|
||||
extern int srs_amf0_strict_array_property_count(srs_amf0_t amf0);
|
||||
extern srs_amf0_t srs_amf0_strict_array_property_at(srs_amf0_t amf0, int index);
|
||||
extern void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value);
|
||||
|
||||
/*************************************************************
|
||||
**************************************************************
|
||||
* utilities
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue