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.

73 lines
2.1KB

  1. /*
  2. * RTP packetization for MPEG video
  3. * Copyright (c) 2002 Fabrice Bellard.
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #include "avformat.h"
  22. #include "rtp_internal.h"
  23. /* NOTE: a single frame must be passed with sequence header if
  24. needed. XXX: use slices. */
  25. void ff_rtp_send_mpegvideo(AVFormatContext *s1, const uint8_t *buf1, int size)
  26. {
  27. RTPDemuxContext *s = s1->priv_data;
  28. AVStream *st = s1->streams[0];
  29. int len, h, max_packet_size;
  30. uint8_t *q;
  31. max_packet_size = s->max_payload_size;
  32. while (size > 0) {
  33. /* XXX: more correct headers */
  34. h = 0;
  35. if (st->codec->sub_id == 2)
  36. h |= 1 << 26; /* mpeg 2 indicator */
  37. q = s->buf;
  38. *q++ = h >> 24;
  39. *q++ = h >> 16;
  40. *q++ = h >> 8;
  41. *q++ = h;
  42. if (st->codec->sub_id == 2) {
  43. h = 0;
  44. *q++ = h >> 24;
  45. *q++ = h >> 16;
  46. *q++ = h >> 8;
  47. *q++ = h;
  48. }
  49. len = max_packet_size - (q - s->buf);
  50. if (len > size)
  51. len = size;
  52. memcpy(q, buf1, len);
  53. q += len;
  54. /* 90 KHz time stamp */
  55. s->timestamp = s->base_timestamp +
  56. av_rescale((int64_t)s->cur_timestamp * st->codec->time_base.num, 90000, st->codec->time_base.den); //FIXME pass timestamps
  57. ff_rtp_send_data(s1, s->buf, q - s->buf, (len == size));
  58. buf1 += len;
  59. size -= len;
  60. }
  61. s->cur_timestamp++;
  62. }