Commit 9b932b8a authored by Ronald S. Bultje's avatar Ronald S. Bultje

Change function prototype of RTPDynamicPayloadHandler.parse_packet() to

not use RTPDemuxContext, but rather take a pointer to the payload context
directly. This allows using payload handlers regardless over the transport
over which they were sent, and prepares for the introduction of a future
RDTDemuxContext. See discussion in "RDT/Realmedia patches #2" thread on ML.

Originally committed as revision 15541 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent ed0aacc7
...@@ -163,14 +163,13 @@ ff_rdt_parse_header(const uint8_t *buf, int len, ...@@ -163,14 +163,13 @@ ff_rdt_parse_header(const uint8_t *buf, int len,
/**< return 0 on packet, no more left, 1 on packet, 1 on partial packet... */ /**< return 0 on packet, no more left, 1 on packet, 1 on partial packet... */
static int static int
rdt_parse_packet (RTPDemuxContext *s, AVPacket *pkt, uint32_t *timestamp, rdt_parse_packet (PayloadContext *rdt, AVStream *st,
AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, int flags) const uint8_t *buf, int len, int flags)
{ {
PayloadContext *rdt = s->dynamic_protocol_context;
int seq = 1, res; int seq = 1, res;
ByteIOContext *pb = rdt->rmctx->pb; ByteIOContext *pb = rdt->rmctx->pb;
RMContext *rm = rdt->rmctx->priv_data; RMContext *rm = rdt->rmctx->priv_data;
AVStream *st = s->st;
if (rm->audio_pkt_cnt == 0) { if (rm->audio_pkt_cnt == 0) {
int pos; int pos;
...@@ -217,7 +216,8 @@ ff_rdt_parse_packet(RTPDemuxContext *s, AVPacket *pkt, ...@@ -217,7 +216,8 @@ ff_rdt_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
if (!buf) { if (!buf) {
/* return the next packets, if any */ /* return the next packets, if any */
timestamp= 0; ///< Should not be used if buf is NULL, but should be set to the timestamp of the packet returned.... timestamp= 0; ///< Should not be used if buf is NULL, but should be set to the timestamp of the packet returned....
rv= s->parse_packet(s, pkt, &timestamp, NULL, 0, flags); rv= s->parse_packet(s->dynamic_protocol_context,
s->st, pkt, &timestamp, NULL, 0, flags);
return rv; return rv;
} }
...@@ -235,7 +235,8 @@ ff_rdt_parse_packet(RTPDemuxContext *s, AVPacket *pkt, ...@@ -235,7 +235,8 @@ ff_rdt_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
len -= rv; len -= rv;
s->seq = seq; s->seq = seq;
rv = s->parse_packet(s, pkt, &timestamp, buf, len, flags); rv = s->parse_packet(s->dynamic_protocol_context,
s->st, pkt, &timestamp, buf, len, flags);
return rv; return rv;
} }
......
...@@ -159,15 +159,13 @@ static void sdp_parse_fmtp_config_h264(AVStream * stream, ...@@ -159,15 +159,13 @@ static void sdp_parse_fmtp_config_h264(AVStream * stream,
} }
// return 0 on packet, no more left, 1 on packet, 1 on partial packet... // return 0 on packet, no more left, 1 on packet, 1 on partial packet...
static int h264_handle_packet(RTPDemuxContext * s, static int h264_handle_packet(PayloadContext *data,
AVStream *st,
AVPacket * pkt, AVPacket * pkt,
uint32_t * timestamp, uint32_t * timestamp,
const uint8_t * buf, const uint8_t * buf,
int len, int flags) int len, int flags)
{ {
#ifdef DEBUG
PayloadContext *data = s->dynamic_protocol_context;
#endif
uint8_t nal = buf[0]; uint8_t nal = buf[0];
uint8_t type = (nal & 0x1f); uint8_t type = (nal & 0x1f);
int result= 0; int result= 0;
......
...@@ -46,13 +46,15 @@ typedef struct PayloadContext PayloadContext; ...@@ -46,13 +46,15 @@ typedef struct PayloadContext PayloadContext;
* Packet parsing for "private" payloads in the RTP specs. * Packet parsing for "private" payloads in the RTP specs.
* *
* @param s stream context * @param s stream context
* @param st stream that this packet belongs to
* @param pkt packet in which to write the parsed data * @param pkt packet in which to write the parsed data
* @param timestamp pointer in which to write the timestamp of this RTP packet * @param timestamp pointer in which to write the timestamp of this RTP packet
* @param buf pointer to raw RTP packet data * @param buf pointer to raw RTP packet data
* @param len length of buf * @param len length of buf
* @param flags flags from the RTP packet header (PKT_FLAG_*) * @param flags flags from the RTP packet header (PKT_FLAG_*)
*/ */
typedef int (*DynamicPayloadPacketHandlerProc) (struct RTPDemuxContext * s, typedef int (*DynamicPayloadPacketHandlerProc) (PayloadContext *s,
AVStream *st,
AVPacket * pkt, AVPacket * pkt,
uint32_t *timestamp, uint32_t *timestamp,
const uint8_t * buf, const uint8_t * buf,
......
...@@ -399,7 +399,8 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, ...@@ -399,7 +399,8 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
/* return the next packets, if any */ /* return the next packets, if any */
if(s->st && s->parse_packet) { if(s->st && s->parse_packet) {
timestamp= 0; ///< Should not be used if buf is NULL, but should be set to the timestamp of the packet returned.... timestamp= 0; ///< Should not be used if buf is NULL, but should be set to the timestamp of the packet returned....
rv= s->parse_packet(s, pkt, &timestamp, NULL, 0, flags); rv= s->parse_packet(s->dynamic_protocol_context,
s->st, pkt, &timestamp, NULL, 0, flags);
finalize_packet(s, pkt, timestamp); finalize_packet(s, pkt, timestamp);
return rv; return rv;
} else { } else {
...@@ -463,7 +464,8 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, ...@@ -463,7 +464,8 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
return 1; return 1;
} }
} else if (s->parse_packet) { } else if (s->parse_packet) {
rv = s->parse_packet(s, pkt, &timestamp, buf, len, flags); rv = s->parse_packet(s->dynamic_protocol_context,
s->st, pkt, &timestamp, buf, len, flags);
} else { } else {
// at this point, the RTP header has been stripped; This is ASSUMING that there is only 1 CSRC, which in't wise. // at this point, the RTP header has been stripped; This is ASSUMING that there is only 1 CSRC, which in't wise.
switch(st->codec->codec_id) { switch(st->codec->codec_id) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment