trtp_rtp_header.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2012 Doubango Telecom <http://www.doubango.org>
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. /**@file trtp_rtp_header.h
  23. * @brief RTP header.
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango.org>
  26. *
  27. */
  28. #ifndef TINYRTP_RTP_HEADER_H
  29. #define TINYRTP_RTP_HEADER_H
  30. #include "tinyrtp_config.h"
  31. #include "tinymedia/tmedia_codec.h"
  32. #include "tsk_buffer.h"
  33. TRTP_BEGIN_DECLS
  34. #define TRTP_RTP_HEADER_MIN_SIZE 12
  35. #define TRTP_RTP_HEADER(self) ((trtp_rtp_header_t*)(self))
  36. typedef struct trtp_rtp_header_s {
  37. TSK_DECLARE_OBJECT;
  38. /* RFC 3550 section 5.1 - RTP Fixed Header Fields
  39. 0 1 2 3
  40. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  41. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  42. |V=2|P|X| CC |M| PT | sequence number |
  43. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  44. | timestamp |
  45. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  46. | synchronization source (SSRC) identifier |
  47. +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  48. | contributing source (CSRC) identifiers |
  49. | .... |
  50. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  51. */
  52. unsigned version:2;
  53. unsigned padding:1;
  54. unsigned extension:1;
  55. unsigned csrc_count:4;
  56. unsigned marker:1;
  57. unsigned payload_type:7;
  58. uint16_t seq_num;
  59. uint32_t timestamp;
  60. uint32_t ssrc;
  61. uint32_t csrc[15];
  62. // for internal use
  63. enum tmedia_codec_id_e codec_id;
  64. }
  65. trtp_rtp_header_t;
  66. TINYRTP_API trtp_rtp_header_t* trtp_rtp_header_create_null();
  67. TINYRTP_API trtp_rtp_header_t* trtp_rtp_header_create(uint32_t ssrc, uint16_t seq_num, uint32_t timestamp, uint8_t payload_type, tsk_bool_t marker);
  68. TINYRTP_API tsk_size_t trtp_rtp_header_guess_serialbuff_size(const trtp_rtp_header_t *self);
  69. TINYRTP_API tsk_size_t trtp_rtp_header_serialize_to(const trtp_rtp_header_t *self, void *buffer, tsk_size_t size);
  70. TINYRTP_API tsk_buffer_t* trtp_rtp_header_serialize(const trtp_rtp_header_t *self);
  71. TINYRTP_API trtp_rtp_header_t* trtp_rtp_header_deserialize(const void *data, tsk_size_t size);
  72. TINYRTP_GEXTERN const tsk_object_def_t *trtp_rtp_header_def_t;
  73. TRTP_END_DECLS
  74. #endif /* TINYRTP_RTP_HEADER_H */