rtmp: add rtmp_meta() to send metadata on stream (#173)

This commit is contained in:
Alfred E. Heggestad 2018-12-10 15:25:42 +01:00 committed by Richard Aas
parent 7c5333c934
commit cd1dd6f315
3 changed files with 24 additions and 2 deletions

View file

@ -99,7 +99,7 @@ int rtmp_amf_request(struct rtmp_conn *conn, uint32_t stream_id,
int rtmp_amf_reply(struct rtmp_conn *conn, uint32_t stream_id, bool success,
const struct odict *req,
unsigned body_propc, ...);
int rtmp_amf_data(struct rtmp_conn *conn, uint32_t stream_id,
int rtmp_amf_data(const struct rtmp_conn *conn, uint32_t stream_id,
const char *command, unsigned body_propc, ...);
@ -125,6 +125,7 @@ int rtmp_stream_create(struct rtmp_stream **strmp, struct rtmp_conn *conn,
void *arg);
int rtmp_play(struct rtmp_stream *strm, const char *name);
int rtmp_publish(struct rtmp_stream *strm, const char *name);
int rtmp_meta(struct rtmp_stream *strm);
int rtmp_send_audio(struct rtmp_stream *strm, uint32_t timestamp,
const uint8_t *pld, size_t len);
int rtmp_send_video(struct rtmp_stream *strm, uint32_t timestamp,

View file

@ -122,7 +122,7 @@ int rtmp_amf_reply(struct rtmp_conn *conn, uint32_t stream_id, bool success,
}
int rtmp_amf_data(struct rtmp_conn *conn, uint32_t stream_id,
int rtmp_amf_data(const struct rtmp_conn *conn, uint32_t stream_id,
const char *command, unsigned body_propc, ...)
{
struct mbuf *mb;

View file

@ -210,6 +210,27 @@ int rtmp_publish(struct rtmp_stream *strm, const char *name)
}
/**
* Send metadata on the stream to the RTMP Server
*
* @param strm RTMP Stream
*
* @return 0 if success, otherwise errorcode
*/
int rtmp_meta(struct rtmp_stream *strm)
{
if (!strm)
return EINVAL;
return rtmp_amf_data(strm->conn, strm->stream_id, "@setDataFrame",
2,
RTMP_AMF_TYPE_STRING, "onMetaData",
RTMP_AMF_TYPE_ECMA_ARRAY, 2,
RTMP_AMF_TYPE_NUMBER, "audiocodecid", 10.0,
RTMP_AMF_TYPE_NUMBER, "videocodecid", 7.0);
}
/**
* Send audio packet on the RTMP Stream
*