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.

58 lines
2.0KB

  1. /*
  2. * RTP packetization for H.261 video (RFC 4587)
  3. * Copyright (c) 2014 Thomas Volkert <thomas@homer-conferencing.com>
  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 "rtpenc.h"
  23. void ff_rtp_send_h261(AVFormatContext *s1, const uint8_t *frame_buf, int frame_size)
  24. {
  25. RTPMuxContext *rtp_ctx = s1->priv_data;
  26. int processed_frame_size;
  27. int last_packet_of_frame;
  28. uint8_t *tmp_buf_ptr;
  29. /* use the default 90 KHz time stamp */
  30. rtp_ctx->timestamp = rtp_ctx->cur_timestamp;
  31. /* continue as long as not all frame data is processed */
  32. while (frame_size > 0) {
  33. tmp_buf_ptr = rtp_ctx->buf;
  34. *tmp_buf_ptr++ = 1; /* V=1 */
  35. *tmp_buf_ptr++ = 0;
  36. *tmp_buf_ptr++ = 0;
  37. *tmp_buf_ptr++ = 0;
  38. processed_frame_size = FFMIN(rtp_ctx->max_payload_size - 4, frame_size);
  39. //XXX: parse the h.261 bitstream and improve frame splitting here
  40. last_packet_of_frame = (processed_frame_size == frame_size);
  41. memcpy(tmp_buf_ptr, frame_buf, processed_frame_size);
  42. tmp_buf_ptr += processed_frame_size;
  43. ff_rtp_send_data(s1, rtp_ctx->buf, tmp_buf_ptr - rtp_ctx->buf, last_packet_of_frame);
  44. frame_buf += processed_frame_size;
  45. frame_size -= processed_frame_size;
  46. }
  47. }