rtp.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * rtp.h
  3. *
  4. * rtp interface for srtp reference implementation
  5. *
  6. * David A. McGrew
  7. * Cisco Systems, Inc.
  8. *
  9. * data types:
  10. *
  11. * rtp_msg_t an rtp message (the data that goes on the wire)
  12. * rtp_sender_t sender side socket and rtp info
  13. * rtp_receiver_t receiver side socket and rtp info
  14. *
  15. */
  16. /*
  17. *
  18. * Copyright (c) 2001-2006, Cisco Systems, Inc.
  19. * All rights reserved.
  20. *
  21. * Redistribution and use in source and binary forms, with or without
  22. * modification, are permitted provided that the following conditions
  23. * are met:
  24. *
  25. * Redistributions of source code must retain the above copyright
  26. * notice, this list of conditions and the following disclaimer.
  27. *
  28. * Redistributions in binary form must reproduce the above
  29. * copyright notice, this list of conditions and the following
  30. * disclaimer in the documentation and/or other materials provided
  31. * with the distribution.
  32. *
  33. * Neither the name of the Cisco Systems, Inc. nor the names of its
  34. * contributors may be used to endorse or promote products derived
  35. * from this software without specific prior written permission.
  36. *
  37. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  38. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  39. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  40. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  41. * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  42. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  43. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  44. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  45. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  46. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  47. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  48. * OF THE POSSIBILITY OF SUCH DAMAGE.
  49. *
  50. */
  51. #ifndef RTP_H
  52. #define RTP_H
  53. #ifdef HAVE_NETINET_IN_H
  54. # include <netinet/in.h>
  55. #elif defined HAVE_WINSOCK2_H
  56. # include <winsock2.h>
  57. #endif
  58. #include "srtp.h"
  59. typedef struct rtp_sender_ctx_t *rtp_sender_t;
  60. typedef struct rtp_receiver_ctx_t *rtp_receiver_t;
  61. int
  62. rtp_sendto(rtp_sender_t sender, const void* msg, int len);
  63. int
  64. rtp_recvfrom(rtp_receiver_t receiver, void *msg, int *len);
  65. int
  66. rtp_receiver_init(rtp_receiver_t rcvr, int sock,
  67. struct sockaddr_in addr, unsigned int ssrc);
  68. int
  69. rtp_sender_init(rtp_sender_t sender, int sock,
  70. struct sockaddr_in addr, unsigned int ssrc);
  71. /*
  72. * srtp_sender_init(...) initializes an rtp_sender_t
  73. */
  74. int
  75. srtp_sender_init(rtp_sender_t rtp_ctx, /* structure to be init'ed */
  76. struct sockaddr_in name, /* socket name */
  77. sec_serv_t security_services, /* sec. servs. to be used */
  78. unsigned char *input_key /* master key/salt in hex */
  79. );
  80. int
  81. srtp_receiver_init(rtp_receiver_t rtp_ctx, /* structure to be init'ed */
  82. struct sockaddr_in name, /* socket name */
  83. sec_serv_t security_services, /* sec. servs. to be used */
  84. unsigned char *input_key /* master key/salt in hex */
  85. );
  86. int
  87. rtp_sender_init_srtp(rtp_sender_t sender, const srtp_policy_t *policy);
  88. int
  89. rtp_sender_deinit_srtp(rtp_sender_t sender);
  90. int
  91. rtp_receiver_init_srtp(rtp_receiver_t sender, const srtp_policy_t *policy);
  92. int
  93. rtp_receiver_deinit_srtp(rtp_receiver_t sender);
  94. rtp_sender_t
  95. rtp_sender_alloc(void);
  96. void
  97. rtp_sender_dealloc(rtp_sender_t rtp_ctx);
  98. rtp_receiver_t
  99. rtp_receiver_alloc(void);
  100. void
  101. rtp_receiver_dealloc(rtp_receiver_t rtp_ctx);
  102. /*
  103. * RTP_HEADER_LEN indicates the size of an RTP header
  104. */
  105. #define RTP_HEADER_LEN 12
  106. /*
  107. * RTP_MAX_BUF_LEN defines the largest RTP packet in the rtp.c implementation
  108. */
  109. #define RTP_MAX_BUF_LEN 16384
  110. #endif /* RTP_H */