gst_plugins_base/gst-libs/gst/rtsp/gstrtspmessage.h
changeset 0 0e761a78d257
child 8 4a7fac7dd34a
equal deleted inserted replaced
-1:000000000000 0:0e761a78d257
       
     1 /* GStreamer
       
     2  * Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
       
     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., 59 Temple Place - Suite 330,
       
    17  * Boston, MA 02111-1307, 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 
       
    43 #ifndef __GST_RTSP_MESSAGE_H__
       
    44 #define __GST_RTSP_MESSAGE_H__
       
    45 
       
    46 #include <glib.h>
       
    47 
       
    48 #include <gst/rtsp/gstrtspdefs.h>
       
    49 
       
    50 G_BEGIN_DECLS
       
    51 
       
    52 /**
       
    53  * GstRTSPMsgType:
       
    54  * @GST_RTSP_MESSAGE_INVALID: invalid message type
       
    55  * @GST_RTSP_MESSAGE_REQUEST: request message
       
    56  * @GST_RTSP_MESSAGE_RESPONSE: response message
       
    57  * @GST_RTSP_MESSAGE_DATA: data message
       
    58  *
       
    59  * The type of a message.
       
    60  */
       
    61 typedef enum
       
    62 {
       
    63   GST_RTSP_MESSAGE_INVALID,
       
    64   GST_RTSP_MESSAGE_REQUEST,
       
    65   GST_RTSP_MESSAGE_RESPONSE,
       
    66   GST_RTSP_MESSAGE_DATA,
       
    67 } GstRTSPMsgType;
       
    68 
       
    69 typedef struct _GstRTSPMessage GstRTSPMessage;
       
    70 
       
    71 /**
       
    72  * GstRTSPMessage:
       
    73  * @type: the message type
       
    74  *
       
    75  * An RTSP message containing request, response or data messages. Depending on
       
    76  * the @type, the appropriate structure may be accessed.
       
    77  */
       
    78 struct _GstRTSPMessage
       
    79 {
       
    80   GstRTSPMsgType    type;
       
    81 
       
    82   union {
       
    83     struct {
       
    84       GstRTSPMethod      method;
       
    85       gchar             *uri;
       
    86       GstRTSPVersion     version;
       
    87     } request;
       
    88     struct {
       
    89       GstRTSPStatusCode  code;
       
    90       gchar             *reason;
       
    91       GstRTSPVersion     version;
       
    92     } response;
       
    93     struct {
       
    94       guint8             channel;
       
    95     } data;
       
    96   } type_data;
       
    97 
       
    98   /*< private >*/
       
    99   GArray        *hdr_fields;
       
   100 
       
   101   guint8        *body;
       
   102   guint          body_size;
       
   103 };
       
   104 
       
   105 /* memory management */
       
   106 GstRTSPResult      gst_rtsp_message_new             (GstRTSPMessage **msg);
       
   107 GstRTSPResult      gst_rtsp_message_init            (GstRTSPMessage *msg);
       
   108 GstRTSPResult      gst_rtsp_message_unset           (GstRTSPMessage *msg);
       
   109 GstRTSPResult      gst_rtsp_message_free            (GstRTSPMessage *msg);
       
   110 
       
   111 GstRTSPMsgType     gst_rtsp_message_get_type        (GstRTSPMessage *msg);
       
   112 
       
   113 /* request */
       
   114 GstRTSPResult      gst_rtsp_message_new_request     (GstRTSPMessage **msg,
       
   115                                                      GstRTSPMethod method,
       
   116                                                      const gchar *uri);
       
   117 GstRTSPResult      gst_rtsp_message_init_request    (GstRTSPMessage *msg,
       
   118                                                      GstRTSPMethod method,
       
   119                                                      const gchar *uri);
       
   120 GstRTSPResult      gst_rtsp_message_parse_request   (GstRTSPMessage *msg,
       
   121                                                      GstRTSPMethod *method,
       
   122                                                      const gchar **uri,
       
   123 						     GstRTSPVersion *version);
       
   124 
       
   125 /* response */
       
   126 GstRTSPResult      gst_rtsp_message_new_response    (GstRTSPMessage **msg,
       
   127                                                      GstRTSPStatusCode code,
       
   128                                                      const gchar *reason,
       
   129                                                      const GstRTSPMessage *request);
       
   130 GstRTSPResult      gst_rtsp_message_init_response   (GstRTSPMessage *msg,
       
   131                                                      GstRTSPStatusCode code,
       
   132                                                      const gchar *reason,
       
   133                                                      const GstRTSPMessage *request);
       
   134 GstRTSPResult      gst_rtsp_message_parse_response  (GstRTSPMessage *msg,
       
   135                                                      GstRTSPStatusCode *code,
       
   136                                                      const gchar **reason,
       
   137                                                      GstRTSPVersion *version);
       
   138 /* data */
       
   139 GstRTSPResult      gst_rtsp_message_new_data        (GstRTSPMessage **msg,
       
   140                                                      guint8 channel);
       
   141 GstRTSPResult      gst_rtsp_message_init_data       (GstRTSPMessage *msg,
       
   142                                                      guint8 channel);
       
   143 GstRTSPResult      gst_rtsp_message_parse_data      (GstRTSPMessage *msg,
       
   144                                                      guint8 *channel);
       
   145 
       
   146 /* headers */
       
   147 GstRTSPResult      gst_rtsp_message_add_header      (GstRTSPMessage *msg,
       
   148                                                      GstRTSPHeaderField field,
       
   149                                                      const gchar *value);
       
   150 GstRTSPResult      gst_rtsp_message_remove_header   (GstRTSPMessage *msg,
       
   151                                                      GstRTSPHeaderField field,
       
   152                                                      gint indx);
       
   153 GstRTSPResult      gst_rtsp_message_get_header      (const GstRTSPMessage *msg,
       
   154                                                      GstRTSPHeaderField field,
       
   155                                                      gchar **value,
       
   156                                                      gint indx);
       
   157 GstRTSPResult      gst_rtsp_message_append_headers  (const GstRTSPMessage *msg,
       
   158                                                      GString *str);
       
   159 
       
   160 /* handling the body */
       
   161 GstRTSPResult      gst_rtsp_message_set_body        (GstRTSPMessage *msg,
       
   162                                                      const guint8 *data,
       
   163                                                      guint size);
       
   164 GstRTSPResult      gst_rtsp_message_take_body       (GstRTSPMessage *msg,
       
   165                                                      guint8 *data,
       
   166                                                      guint size);
       
   167 GstRTSPResult      gst_rtsp_message_get_body        (const GstRTSPMessage *msg,
       
   168                                                      guint8 **data,
       
   169                                                      guint *size);
       
   170 GstRTSPResult      gst_rtsp_message_steal_body      (GstRTSPMessage *msg,
       
   171                                                      guint8 **data,
       
   172                                                      guint *size);
       
   173 
       
   174 /* debug */
       
   175 GstRTSPResult      gst_rtsp_message_dump            (GstRTSPMessage *msg);
       
   176 
       
   177 G_END_DECLS
       
   178 
       
   179 #endif /* __GST_RTSP_MESSAGE_H__ */