gstrtspmessage.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /* GStreamer
  2. * Copyright (C) <2005,2006> Wim Taymans <[email protected]>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. /*
  20. * Unless otherwise indicated, Source Code is licensed under MIT license.
  21. * See further explanation attached in License Statement (distributed in the file
  22. * LICENSE).
  23. *
  24. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  25. * this software and associated documentation files (the "Software"), to deal in
  26. * the Software without restriction, including without limitation the rights to
  27. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  28. * of the Software, and to permit persons to whom the Software is furnished to do
  29. * so, subject to the following conditions:
  30. *
  31. * The above copyright notice and this permission notice shall be included in all
  32. * copies or substantial portions of the Software.
  33. *
  34. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  35. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  36. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  37. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  38. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  39. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  40. * SOFTWARE.
  41. */
  42. #ifndef __GST_RTSP_MESSAGE_H__
  43. #define __GST_RTSP_MESSAGE_H__
  44. #include <gst/gst.h>
  45. #include <gst/rtsp/gstrtspdefs.h>
  46. G_BEGIN_DECLS
  47. /**
  48. * GstRTSPMsgType:
  49. * @GST_RTSP_MESSAGE_INVALID: invalid message type
  50. * @GST_RTSP_MESSAGE_REQUEST: RTSP request message
  51. * @GST_RTSP_MESSAGE_RESPONSE: RTSP response message
  52. * @GST_RTSP_MESSAGE_HTTP_REQUEST: HTTP request message.
  53. * @GST_RTSP_MESSAGE_HTTP_RESPONSE: HTTP response message.
  54. * @GST_RTSP_MESSAGE_DATA: data message
  55. *
  56. * The type of a message.
  57. */
  58. typedef enum
  59. {
  60. GST_RTSP_MESSAGE_INVALID,
  61. GST_RTSP_MESSAGE_REQUEST,
  62. GST_RTSP_MESSAGE_RESPONSE,
  63. GST_RTSP_MESSAGE_HTTP_REQUEST,
  64. GST_RTSP_MESSAGE_HTTP_RESPONSE,
  65. GST_RTSP_MESSAGE_DATA
  66. } GstRTSPMsgType;
  67. typedef struct _GstRTSPMessage GstRTSPMessage;
  68. /**
  69. * GstRTSPMessage:
  70. * @type: the message type
  71. *
  72. * An RTSP message containing request, response or data messages. Depending on
  73. * the @type, the appropriate structure may be accessed.
  74. */
  75. struct _GstRTSPMessage
  76. {
  77. GstRTSPMsgType type;
  78. union {
  79. struct {
  80. GstRTSPMethod method;
  81. gchar *uri;
  82. GstRTSPVersion version;
  83. } request;
  84. struct {
  85. GstRTSPStatusCode code;
  86. gchar *reason;
  87. GstRTSPVersion version;
  88. } response;
  89. struct {
  90. guint8 channel;
  91. } data;
  92. } type_data;
  93. /*< private >*/
  94. GArray *hdr_fields;
  95. guint8 *body;
  96. guint body_size;
  97. gpointer _gst_reserved[GST_PADDING];
  98. };
  99. /* memory management */
  100. GstRTSPResult gst_rtsp_message_new (GstRTSPMessage **msg);
  101. GstRTSPResult gst_rtsp_message_init (GstRTSPMessage *msg);
  102. GstRTSPResult gst_rtsp_message_unset (GstRTSPMessage *msg);
  103. GstRTSPResult gst_rtsp_message_free (GstRTSPMessage *msg);
  104. GstRTSPMsgType gst_rtsp_message_get_type (GstRTSPMessage *msg);
  105. /* request */
  106. GstRTSPResult gst_rtsp_message_new_request (GstRTSPMessage **msg,
  107. GstRTSPMethod method,
  108. const gchar *uri);
  109. GstRTSPResult gst_rtsp_message_init_request (GstRTSPMessage *msg,
  110. GstRTSPMethod method,
  111. const gchar *uri);
  112. GstRTSPResult gst_rtsp_message_parse_request (GstRTSPMessage *msg,
  113. GstRTSPMethod *method,
  114. const gchar **uri,
  115. GstRTSPVersion *version);
  116. /* response */
  117. GstRTSPResult gst_rtsp_message_new_response (GstRTSPMessage **msg,
  118. GstRTSPStatusCode code,
  119. const gchar *reason,
  120. const GstRTSPMessage *request);
  121. GstRTSPResult gst_rtsp_message_init_response (GstRTSPMessage *msg,
  122. GstRTSPStatusCode code,
  123. const gchar *reason,
  124. const GstRTSPMessage *request);
  125. GstRTSPResult gst_rtsp_message_parse_response (GstRTSPMessage *msg,
  126. GstRTSPStatusCode *code,
  127. const gchar **reason,
  128. GstRTSPVersion *version);
  129. /* data */
  130. GstRTSPResult gst_rtsp_message_new_data (GstRTSPMessage **msg,
  131. guint8 channel);
  132. GstRTSPResult gst_rtsp_message_init_data (GstRTSPMessage *msg,
  133. guint8 channel);
  134. GstRTSPResult gst_rtsp_message_parse_data (GstRTSPMessage *msg,
  135. guint8 *channel);
  136. /* headers */
  137. GstRTSPResult gst_rtsp_message_add_header (GstRTSPMessage *msg,
  138. GstRTSPHeaderField field,
  139. const gchar *value);
  140. GstRTSPResult gst_rtsp_message_take_header (GstRTSPMessage *msg,
  141. GstRTSPHeaderField field,
  142. gchar *value);
  143. GstRTSPResult gst_rtsp_message_remove_header (GstRTSPMessage *msg,
  144. GstRTSPHeaderField field,
  145. gint indx);
  146. GstRTSPResult gst_rtsp_message_get_header (const GstRTSPMessage *msg,
  147. GstRTSPHeaderField field,
  148. gchar **value,
  149. gint indx);
  150. GstRTSPResult gst_rtsp_message_append_headers (const GstRTSPMessage *msg,
  151. GString *str);
  152. /* handling the body */
  153. GstRTSPResult gst_rtsp_message_set_body (GstRTSPMessage *msg,
  154. const guint8 *data,
  155. guint size);
  156. GstRTSPResult gst_rtsp_message_take_body (GstRTSPMessage *msg,
  157. guint8 *data,
  158. guint size);
  159. GstRTSPResult gst_rtsp_message_get_body (const GstRTSPMessage *msg,
  160. guint8 **data,
  161. guint *size);
  162. GstRTSPResult gst_rtsp_message_steal_body (GstRTSPMessage *msg,
  163. guint8 **data,
  164. guint *size);
  165. /* debug */
  166. GstRTSPResult gst_rtsp_message_dump (GstRTSPMessage *msg);
  167. G_END_DECLS
  168. #endif /* __GST_RTSP_MESSAGE_H__ */