mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 15:51:11 +00:00
9c8ea35617
Original commit message from CVS: * gst/avi/gstavimux.c: Comment a #if 0 in caps template definition as VS6 seems to do not support it. * gst/rtsp/gstrtspsrc.c:(gst_rtspsrc_loop_udp): Use gst_guint64_to_gdouble for conversion. * gst/rtsp/rtspconnection.c:(rtsp_connection_send): Move variables declaration before the first instruction. * gst/rtsp/rtspdefs.c:(rtsp_strresult): Don't use hstrerror for error log on G_OS_WIN32 build as it's not supported. And don't include netdb.h for G_OS_WIN32 * gst/rtsp/sdpmessage.c:(sdp_parse_line): This initialization SDPMedia nmedia = {.media = NULL }; is not supported by VS6 then use an other way to initialize SDPMedia structure. * gst/udp/gstdynudpsink.h: * gst/udp/gstdynudpnetutils.h: Do not include <sys/time.h> for G_OS_WIN32 * gst/udp/gstudpsrc.c: Define socklen_t as int for G_OS_WIN32 * win/common/config.h.in: Undef HAVE_NETINET_IN_H * win32/vs6/gst_plugins_good.dsw: * win32/vs6/libgstrtp.dsp: * win32/vs6/libgstrtsp.dsp: * win32/vs6/libgstautogen.dsp: * win32/vs6/libgstaudiofx.dsp: * win32/vs6/libgstudp.dsp: Add and update project files. * win32/common/gstudp-enumtypes.c: * win32/common/gstudp-enumtypes.h: Add a copy of udp enumtypes to win32/common as in core and base.
300 lines
11 KiB
C
300 lines
11 KiB
C
/* GStreamer
|
|
* Copyright (C) <2005,2006> Wim Taymans <wim@fluendo.com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
/*
|
|
* Unless otherwise indicated, Source Code is licensed under MIT license.
|
|
* See further explanation attached in License Statement (distributed in the file
|
|
* LICENSE).
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
* this software and associated documentation files (the "Software"), to deal in
|
|
* the Software without restriction, including without limitation the rights to
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
* of the Software, and to permit persons to whom the Software is furnished to do
|
|
* so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
#include <errno.h>
|
|
|
|
extern int h_errno;
|
|
|
|
#include "rtspdefs.h"
|
|
|
|
#ifndef G_OS_WIN32
|
|
#include <netdb.h>
|
|
#endif
|
|
|
|
static const gchar *rtsp_results[] = {
|
|
"OK",
|
|
/* errors */
|
|
"Generic error",
|
|
"Invalid parameter specified",
|
|
"Operation interrupted",
|
|
"Out of memory",
|
|
"Cannot resolve host",
|
|
"Function not implemented",
|
|
"System error: %s",
|
|
"Parse error",
|
|
"Error on WSAStartup",
|
|
"Windows sockets are not version 0x202",
|
|
"Received end-of-file",
|
|
"Network error: %s",
|
|
"Host is not a valid IP address",
|
|
"Unknown error (%d)",
|
|
NULL
|
|
};
|
|
|
|
static const gchar *rtsp_methods[] = {
|
|
"DESCRIBE",
|
|
"ANNOUNCE",
|
|
"GET_PARAMETER",
|
|
"OPTIONS",
|
|
"PAUSE",
|
|
"PLAY",
|
|
"RECORD",
|
|
"REDIRECT",
|
|
"SETUP",
|
|
"SET_PARAMETER",
|
|
"TEARDOWN",
|
|
NULL
|
|
};
|
|
|
|
static const gchar *rtsp_headers[] = {
|
|
"Accept", /* Accept R opt. entity */
|
|
"Accept-Encoding", /* Accept-Encoding R opt. entity */
|
|
"Accept-Language", /* Accept-Language R opt. all */
|
|
"Allow", /* Allow r opt. all */
|
|
"Authorization", /* Authorization R opt. all */
|
|
"Bandwidth", /* Bandwidth R opt. all */
|
|
"Blocksize", /* Blocksize R opt. all but OPTIONS, TEARDOWN */
|
|
"Cache-Control", /* Cache-Control g opt. SETUP */
|
|
"Conference", /* Conference R opt. SETUP */
|
|
"Connection", /* Connection g req. all */
|
|
"Content-Base", /* Content-Base e opt. entity */
|
|
"Content-Encoding", /* Content-Encoding e req. SET_PARAMETER, DESCRIBE, ANNOUNCE */
|
|
"Content-Language", /* Content-Language e req. DESCRIBE, ANNOUNCE */
|
|
"Content-Length", /* Content-Length e req. SET_PARAMETER, ANNOUNCE, entity */
|
|
"Content-Location", /* Content-Location e opt. entity */
|
|
"Content-Type", /* Content-Type e req. SET_PARAMETER, ANNOUNCE, entity */
|
|
"CSeq", /* CSeq g req. all */
|
|
"Date", /* Date g opt. all */
|
|
"Expires", /* Expires e opt. DESCRIBE, ANNOUNCE */
|
|
"From", /* From R opt. all */
|
|
"If-Modified-Since", /* If-Modified-Since R opt. DESCRIBE, SETUP */
|
|
"Last-Modified", /* Last-Modified e opt. entity */
|
|
"Proxy-Authenticate", /* Proxy-Authenticate */
|
|
"Proxy-Require", /* Proxy-Require R req. all */
|
|
"Public", /* Public r opt. all */
|
|
"Range", /* Range Rr opt. PLAY, PAUSE, RECORD */
|
|
"Referer", /* Referer R opt. all */
|
|
"Require", /* Require R req. all */
|
|
"Retry-After", /* Retry-After r opt. all */
|
|
"RTP-Info", /* RTP-Info r req. PLAY */
|
|
"Scale", /* Scale Rr opt. PLAY, RECORD */
|
|
"Session", /* Session Rr req. all but SETUP, OPTIONS */
|
|
"Server", /* Server r opt. all */
|
|
"Speed", /* Speed Rr opt. PLAY */
|
|
"Transport", /* Transport Rr req. SETUP */
|
|
"Unsupported", /* Unsupported r req. all */
|
|
"User-Agent", /* User-Agent R opt. all */
|
|
"Via", /* Via g opt. all */
|
|
"WWW-Authenticate", /* WWW-Authenticate r opt. all */
|
|
|
|
/* Real extensions */
|
|
"ClientChallenge", /* ClientChallenge */
|
|
"RealChallenge1", /* RealChallenge1 */
|
|
"RealChallenge2", /* RealChallenge2 */
|
|
"RealChallenge3", /* RealChallenge3 */
|
|
"Subscribe", /* Subscribe */
|
|
"Alert", /* Alert */
|
|
"ClientID", /* ClientID */
|
|
"CompanyID", /* CompanyID */
|
|
"GUID", /* GUID */
|
|
"RegionData", /* RegionData */
|
|
"SupportsMaximumASMBandwidth", /* SupportsMaximumASMBandwidth */
|
|
"Language", /* Language */
|
|
"PlayerStarttime", /* PlayerStarttime */
|
|
|
|
NULL
|
|
};
|
|
|
|
#define DEF_STATUS(c, t) \
|
|
g_hash_table_insert (statuses, GUINT_TO_POINTER(c), t)
|
|
|
|
GHashTable *
|
|
rtsp_init_status (void)
|
|
{
|
|
GHashTable *statuses = g_hash_table_new (NULL, NULL);
|
|
|
|
DEF_STATUS (RTSP_STS_CONTINUE, "Continue");
|
|
DEF_STATUS (RTSP_STS_OK, "OK");
|
|
DEF_STATUS (RTSP_STS_CREATED, "Created");
|
|
DEF_STATUS (RTSP_STS_LOW_ON_STORAGE, "Low on Storage Space");
|
|
DEF_STATUS (RTSP_STS_MULTIPLE_CHOICES, "Multiple Choices");
|
|
DEF_STATUS (RTSP_STS_MOVED_PERMANENTLY, "Moved Permanently");
|
|
DEF_STATUS (RTSP_STS_MOVE_TEMPORARILY, "Moved Temporarily");
|
|
DEF_STATUS (RTSP_STS_SEE_OTHER, "See Other");
|
|
DEF_STATUS (RTSP_STS_NOT_MODIFIED, "Not Modified");
|
|
DEF_STATUS (RTSP_STS_USE_PROXY, "Use Proxy");
|
|
DEF_STATUS (RTSP_STS_BAD_REQUEST, "Bad Request");
|
|
DEF_STATUS (RTSP_STS_UNAUTHORIZED, "Unauthorized");
|
|
DEF_STATUS (RTSP_STS_PAYMENT_REQUIRED, "Payment Required");
|
|
DEF_STATUS (RTSP_STS_FORBIDDEN, "Forbidden");
|
|
DEF_STATUS (RTSP_STS_NOT_FOUND, "Not Found");
|
|
DEF_STATUS (RTSP_STS_METHOD_NOT_ALLOWED, "Method Not Allowed");
|
|
DEF_STATUS (RTSP_STS_NOT_ACCEPTABLE, "Not Acceptable");
|
|
DEF_STATUS (RTSP_STS_PROXY_AUTH_REQUIRED, "Proxy Authentication Required");
|
|
DEF_STATUS (RTSP_STS_REQUEST_TIMEOUT, "Request Time-out");
|
|
DEF_STATUS (RTSP_STS_GONE, "Gone");
|
|
DEF_STATUS (RTSP_STS_LENGTH_REQUIRED, "Length Required");
|
|
DEF_STATUS (RTSP_STS_PRECONDITION_FAILED, "Precondition Failed");
|
|
DEF_STATUS (RTSP_STS_REQUEST_ENTITY_TOO_LARGE, "Request Entity Too Large");
|
|
DEF_STATUS (RTSP_STS_REQUEST_URI_TOO_LARGE, "Request-URI Too Large");
|
|
DEF_STATUS (RTSP_STS_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type");
|
|
DEF_STATUS (RTSP_STS_PARAMETER_NOT_UNDERSTOOD, "Parameter Not Understood");
|
|
DEF_STATUS (RTSP_STS_CONFERENCE_NOT_FOUND, "Conference Not Found");
|
|
DEF_STATUS (RTSP_STS_NOT_ENOUGH_BANDWIDTH, "Not Enough Bandwidth");
|
|
DEF_STATUS (RTSP_STS_SESSION_NOT_FOUND, "Session Not Found");
|
|
DEF_STATUS (RTSP_STS_METHOD_NOT_VALID_IN_THIS_STATE,
|
|
"Method Not Valid in This State");
|
|
DEF_STATUS (RTSP_STS_HEADER_FIELD_NOT_VALID_FOR_RESOURCE,
|
|
"Header Field Not Valid for Resource");
|
|
DEF_STATUS (RTSP_STS_INVALID_RANGE, "Invalid Range");
|
|
DEF_STATUS (RTSP_STS_PARAMETER_IS_READONLY, "Parameter Is Read-Only");
|
|
DEF_STATUS (RTSP_STS_AGGREGATE_OPERATION_NOT_ALLOWED,
|
|
"Aggregate operation not allowed");
|
|
DEF_STATUS (RTSP_STS_ONLY_AGGREGATE_OPERATION_ALLOWED,
|
|
"Only aggregate operation allowed");
|
|
DEF_STATUS (RTSP_STS_UNSUPPORTED_TRANSPORT, "Unsupported transport");
|
|
DEF_STATUS (RTSP_STS_DESTINATION_UNREACHABLE, "Destination unreachable");
|
|
DEF_STATUS (RTSP_STS_INTERNAL_SERVER_ERROR, "Internal Server Error");
|
|
DEF_STATUS (RTSP_STS_NOT_IMPLEMENTED, "Not Implemented");
|
|
DEF_STATUS (RTSP_STS_BAD_GATEWAY, "Bad Gateway");
|
|
DEF_STATUS (RTSP_STS_SERVICE_UNAVAILABLE, "Service Unavailable");
|
|
DEF_STATUS (RTSP_STS_GATEWAY_TIMEOUT, "Gateway Time-out");
|
|
DEF_STATUS (RTSP_STS_RTSP_VERSION_NOT_SUPPORTED,
|
|
"RTSP Version not supported");
|
|
DEF_STATUS (RTSP_STS_OPTION_NOT_SUPPORTED, "Option not supported");
|
|
|
|
return statuses;
|
|
}
|
|
|
|
gchar *
|
|
rtsp_strresult (RTSPResult result)
|
|
{
|
|
gint idx;
|
|
gchar *res;
|
|
|
|
idx = ABS (result);
|
|
idx = CLAMP (idx, 0, -RTSP_ELAST);
|
|
|
|
switch (idx) {
|
|
case -RTSP_ESYS:
|
|
res = g_strdup_printf (rtsp_results[idx], g_strerror (errno));
|
|
break;
|
|
case -RTSP_ENET:
|
|
#ifndef G_OS_WIN32
|
|
res = g_strdup_printf (rtsp_results[idx], hstrerror (h_errno));
|
|
#else
|
|
res =
|
|
g_strdup
|
|
("not supported on win32, implement me in a different way ??");
|
|
#endif
|
|
break;
|
|
case -RTSP_ELAST:
|
|
res = g_strdup_printf (rtsp_results[idx], result);
|
|
break;
|
|
default:
|
|
res = g_strdup (rtsp_results[idx]);
|
|
break;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
const gchar *
|
|
rtsp_method_as_text (RTSPMethod method)
|
|
{
|
|
gint i;
|
|
|
|
if (method == RTSP_INVALID)
|
|
return NULL;
|
|
|
|
i = 0;
|
|
while ((method & 1) == 0) {
|
|
i++;
|
|
method >>= 1;
|
|
}
|
|
return rtsp_methods[i];
|
|
}
|
|
|
|
const gchar *
|
|
rtsp_header_as_text (RTSPHeaderField field)
|
|
{
|
|
if (field == RTSP_HDR_INVALID)
|
|
return NULL;
|
|
else
|
|
return rtsp_headers[field - 1];
|
|
}
|
|
|
|
const gchar *
|
|
rtsp_status_as_text (RTSPStatusCode code)
|
|
{
|
|
static GHashTable *statuses;
|
|
|
|
if (G_UNLIKELY (statuses == NULL))
|
|
statuses = rtsp_init_status ();
|
|
|
|
return g_hash_table_lookup (statuses, GUINT_TO_POINTER (code));
|
|
}
|
|
|
|
RTSPHeaderField
|
|
rtsp_find_header_field (gchar * header)
|
|
{
|
|
gint idx;
|
|
|
|
for (idx = 0; rtsp_headers[idx]; idx++) {
|
|
if (g_ascii_strcasecmp (rtsp_headers[idx], header) == 0) {
|
|
return idx + 1;
|
|
}
|
|
}
|
|
return RTSP_HDR_INVALID;
|
|
}
|
|
|
|
RTSPMethod
|
|
rtsp_find_method (gchar * method)
|
|
{
|
|
gint idx;
|
|
|
|
for (idx = 0; rtsp_methods[idx]; idx++) {
|
|
if (g_ascii_strcasecmp (rtsp_methods[idx], method) == 0) {
|
|
return (1 << idx);
|
|
}
|
|
}
|
|
return RTSP_INVALID;
|
|
}
|