You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rtp-mp4v-es-unpack.c 1.3KB

5 months ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /// RFC6416 RTP Payload Format for MPEG-4 Audio/Visual Streams
  2. #include "rtp-packet.h"
  3. #include "rtp-payload-helper.h"
  4. #include "rtp-payload-internal.h"
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <assert.h>
  9. #include <errno.h>
  10. static int rtp_decode_mp4v_es(void* p, const void* packet, int bytes)
  11. {
  12. struct rtp_packet_t pkt;
  13. struct rtp_payload_helper_t *helper;
  14. helper = (struct rtp_payload_helper_t *)p;
  15. if (!helper || 0 != rtp_packet_deserialize(&pkt, packet, bytes))
  16. return -EINVAL;
  17. rtp_payload_check(helper, &pkt);
  18. // save payload
  19. assert(pkt.payloadlen > 0);
  20. if (!helper->lost && pkt.payload && pkt.payloadlen > 0)
  21. {
  22. if (0 != rtp_payload_write(helper, &pkt))
  23. return -ENOMEM;
  24. }
  25. // 5.1. Use of RTP Header Fields for MPEG-4 Visual (p9)
  26. // Marker (M) bit: The marker bit is set to 1 to indicate the last RTP
  27. // packet(or only RTP packet) of a VOP.When multiple VOPs are carried
  28. // in the same RTP packet, the marker bit is set to 1.
  29. if (pkt.rtp.m)
  30. {
  31. rtp_payload_onframe(helper);
  32. }
  33. return helper->lost ? 0 : 1; // packet handled
  34. }
  35. struct rtp_payload_decode_t *rtp_mp4v_es_decode()
  36. {
  37. static struct rtp_payload_decode_t decode = {
  38. rtp_payload_helper_create,
  39. rtp_payload_helper_destroy,
  40. rtp_decode_mp4v_es,
  41. };
  42. return &decode;
  43. }