Commit 34b7837a authored by Christophe Massiot's avatar Christophe Massiot

* modules/access/udp.c: Merged the UDP and RTP plug-ins, with autodetection of RTP,

* src/misc/darwin_specific.m: if $LANG isn't set, retrieve NSUserDefaults.
parent 4da234d7
......@@ -308,10 +308,12 @@ lib_LIBRARIES += lib/libvlc.a $(LIBRARIES_libvlc_pic)
lib_libvlc_a_SOURCES = $(SOURCES_libvlc)
lib_libvlc_a_CFLAGS = $(CPPFLAGS_default) -D__VLC__ $(CFLAGS_default) @CFLAGS_vlc@
lib_libvlc_a_CXXFLAGS = $(CPPFLAGS_default) -D__VLC__ $(CXXFLAGS_default)
lib_libvlc_a_OBJCFLAGS = $(CPPFLAGS_default) -D__VLC__ $(OBJCFLAGS_default)
lib_libvlc_pic_a_SOURCES = $(SOURCES_libvlc)
lib_libvlc_pic_a_CFLAGS = $(CPPFLAGS_pic) -D__VLC__ $(CFLAGS_pic) @CFLAGS_vlc@
lib_libvlc_pic_a_CXXFLAGS = $(CPPFLAGS_pic) -D__VLC__ $(CXXFLAGS_pic)
lib_libvlc_pic_a_OBJCFLAGS = $(CPPFLAGS_pic) -D__VLC__ $(OBJCFLAGS_pic)
if HAVE_BEOS
OPT_SOURCES_libvlc_beos = $(SOURCES_libvlc_beos)
......@@ -345,7 +347,7 @@ SOURCES_libvlc_beos = \
$(NULL)
SOURCES_libvlc_darwin = \
src/misc/darwin_specific.c \
src/misc/darwin_specific.m \
$(NULL)
SOURCES_libvlc_win32 = \
......
dnl Autoconf settings for vlc
AC_INIT(vlc,0.5.0-cvs)
AC_INIT(vlc,0.5.0-test2)
CONFIGURE_LINE="$0 $*"
CODENAME="Natalya"
......@@ -124,7 +124,6 @@ case "x${target_os}" in
LDFLAGS_ipv6="${LDFLAGS_ipv6} -lws2_32"
LDFLAGS_access_http="${LDFLAGS_access_http} -lws2_32"
LDFLAGS_access_mms="${LDFLAGS_access_mms} -lws2_32"
LDFLAGS_access_rtp="${LDFLAGS_access_rtp} -lws2_32"
LDFLAGS_access_udp="${LDFLAGS_access_udp} -lws2_32"
LDFLAGS_access_ftp="${LDFLAGS_access_ftp} -lws2_32"
LDFLAGS_access_output_udp="${LDFLAGS_access_output_udp} -lws2_32"
......@@ -278,7 +277,6 @@ AC_CHECK_FUNC(send,,[
AC_CHECK_LIB(socket,send,
LDFLAGS_access_http="${LDFLAGS_access_http} -lsocket"
LDFLAGS_access_mms="${LDFLAGS_access_mms} -lsocket"
LDFLAGS_access_rtp="${LDFLAGS_access_rtp} -lsocket"
LDFLAGS_access_udp="${LDFLAGS_access_udp} -lsocket"
LDFLAGS_access_ftp="${LDFLAGS_access_ftp} -lsocket"
LDFLAGS_sap="${LDFLAGS_sap} -lsocket"
......@@ -737,7 +735,7 @@ PLUGINS="${PLUGINS} aout_file"
PLUGINS="${PLUGINS} i420_rgb i420_yuy2 i422_yuy2 i420_ymga"
PLUGINS="${PLUGINS} id3 m3u"
PLUGINS="${PLUGINS} wav araw demuxdump demuxsub adpcm"
PLUGINS="${PLUGINS} access_udp access_http access_rtp ipv4 access_mms sap access_ftp"
PLUGINS="${PLUGINS} access_udp access_http ipv4 access_mms access_ftp sap"
dnl
dnl Accelerated modules
......
SOURCES_access_file = modules/access/file.c
SOURCES_access_udp = modules/access/udp.c
SOURCES_access_http = modules/access/http.c
SOURCES_access_rtp = modules/access/rtp.c
SOURCES_access_ftp = modules/access/ftp.c
......@@ -2,7 +2,7 @@
* mms.c: MMS access plug-in
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: mms.c,v 1.14 2002/12/18 14:17:09 sam Exp $
* $Id: mms.c,v 1.15 2002/12/30 08:56:19 massiot Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -116,6 +116,11 @@ static void mms_ParseURL( url_t *p_url, char *psz_url );
/*
* Merci :))
*/
/*
* Vous pourriez signer vos commentaires (mme si on voit bien qui peut
* crire ce genre de trucs :p), et crire en anglais, bordel de
* merde :p.
*/
/*****************************************************************************
* Module descriptor
......
This diff is collapsed.
/*****************************************************************************
* udp.c: raw UDP access plug-in
* udp.c: raw UDP & RTP access plug-in
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: udp.c,v 1.7 2002/12/16 16:48:04 gbazin Exp $
* $Id: udp.c,v 1.8 2002/12/30 08:56:19 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Tristan Leteurtre <tooney@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -52,12 +53,16 @@
#include "network.h"
#define RTP_HEADER_LEN 12
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static ssize_t Read ( input_thread_t *, byte_t *, size_t );
static ssize_t RTPRead ( input_thread_t *, byte_t *, size_t );
static ssize_t RTPChoose( input_thread_t *, byte_t *, size_t );
/*****************************************************************************
* Module descriptor
......@@ -217,7 +222,7 @@ static int Open( vlc_object_t *p_this )
i_bind_port = config_GetInt( p_this, "server-port" );
}
p_input->pf_read = Read;
p_input->pf_read = RTPChoose;
p_input->pf_set_program = input_SetProgram;
p_input->pf_set_area = NULL;
p_input->pf_seek = NULL;
......@@ -348,3 +353,132 @@ static ssize_t Read( input_thread_t * p_input, byte_t * p_buffer, size_t i_len )
#endif
}
/*****************************************************************************
* RTPRead : read from the network, and parse the RTP header
*****************************************************************************/
static ssize_t RTPRead( input_thread_t * p_input, byte_t * p_buffer,
size_t i_len )
{
int i_rtp_version;
int i_CSRC_count;
int i_payload_type;
byte_t * p_tmp_buffer = alloca( p_input->i_mtu );
/* Get the raw data from the socket.
* We first assume that RTP header size is the classic RTP_HEADER_LEN. */
ssize_t i_ret = Read( p_input, p_tmp_buffer, p_input->i_mtu );
if ( !i_ret ) return 0;
/* Parse the header and make some verifications.
* See RFC 1889 & RFC 2250. */
i_rtp_version = ( p_tmp_buffer[0] & 0xC0 ) >> 6;
i_CSRC_count = ( p_tmp_buffer[0] & 0x0F );
i_payload_type = ( p_tmp_buffer[1] & 0x7F );
if ( i_rtp_version != 2 )
msg_Dbg( p_input, "RTP version is %u, should be 2", i_rtp_version );
if ( i_payload_type != 33 && i_payload_type != 14
&& i_payload_type != 32 )
msg_Dbg( p_input, "unsupported RTP payload type (%u)", i_payload_type );
/* Return the packet without the RTP header. */
i_ret -= ( RTP_HEADER_LEN + 4 * i_CSRC_count );
if ( (size_t)i_ret > i_len )
{
/* This should NOT happen. */
msg_Warn( p_input, "RTP input trashing %d bytes", i_ret - i_len );
i_ret = i_len;
}
p_input->p_vlc->pf_memcpy( p_buffer,
p_tmp_buffer + RTP_HEADER_LEN + 4 * i_CSRC_count,
i_ret );
return i_ret;
}
/*****************************************************************************
* RTPChoose : read from the network, and decide whether it's UDP or RTP
*****************************************************************************/
static ssize_t RTPChoose( input_thread_t * p_input, byte_t * p_buffer,
size_t i_len )
{
int i_rtp_version;
int i_CSRC_count;
int i_payload_type;
byte_t * p_tmp_buffer = alloca( p_input->i_mtu );
/* Get the raw data from the socket.
* We first assume that RTP header size is the classic RTP_HEADER_LEN. */
ssize_t i_ret = Read( p_input, p_tmp_buffer, p_input->i_mtu );
if ( !i_ret ) return 0;
/* Check that it's not TS. */
if ( p_tmp_buffer[0] == 0x47 )
{
msg_Dbg( p_input, "detected TS over raw UDP" );
p_input->pf_read = Read;
p_input->p_vlc->pf_memcpy( p_buffer, p_tmp_buffer, i_ret );
return i_ret;
}
/* Parse the header and make some verifications.
* See RFC 1889 & RFC 2250. */
i_rtp_version = ( p_tmp_buffer[0] & 0xC0 ) >> 6;
i_CSRC_count = ( p_tmp_buffer[0] & 0x0F );
i_payload_type = ( p_tmp_buffer[1] & 0x7F );
if ( i_rtp_version != 2 )
{
msg_Dbg( p_input, "no RTP header detected" );
p_input->pf_read = Read;
p_input->p_vlc->pf_memcpy( p_buffer, p_tmp_buffer, i_ret );
return i_ret;
}
switch ( i_payload_type )
{
case 33:
msg_Dbg( p_input, "detected TS over RTP" );
break;
case 14:
msg_Dbg( p_input, "detected MPEG audio over RTP" );
break;
case 32:
msg_Dbg( p_input, "detected MPEG video over RTP" );
break;
default:
msg_Dbg( p_input, "no RTP header detected" );
p_input->pf_read = Read;
p_input->p_vlc->pf_memcpy( p_buffer, p_tmp_buffer, i_ret );
return i_ret;
}
/* Return the packet without the RTP header. */
p_input->pf_read = RTPRead;
i_ret -= ( RTP_HEADER_LEN + 4 * i_CSRC_count );
if ( (size_t)i_ret > i_len )
{
/* This should NOT happen. */
msg_Warn( p_input, "RTP input trashing %d bytes", i_ret - i_len );
i_ret = i_len;
}
p_input->p_vlc->pf_memcpy( p_buffer,
p_tmp_buffer + RTP_HEADER_LEN + 4 * i_CSRC_count,
i_ret );
return i_ret;
}
/*****************************************************************************
* darwin_specific.c: Darwin specific features
* darwin_specific.m: Darwin specific features
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: darwin_specific.c,v 1.16 2002/12/27 00:17:49 massiot Exp $
* $Id: darwin_specific.m,v 1.1 2002/12/30 08:56:19 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Christophe Massiot <massiot@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -25,14 +26,74 @@
#include <vlc/vlc.h>
#include <Cocoa/Cocoa.h>
/*****************************************************************************
* Static vars
*****************************************************************************/
static char * psz_program_path;
/*****************************************************************************
* system_Init: fill in program path.
* system_Init: fill in program path & retrieve language
*****************************************************************************/
static int FindLanguage( const char * psz_lang )
{
const char * psz_short = NULL;
if ( !strcmp(psz_lang, "German") )
{
psz_short = "de";
}
else if ( !strcmp(psz_lang, "British") )
{
psz_short = "en_GB";
}
else if ( !strcmp(psz_lang, "French") )
{
psz_short = "fr";
}
else if ( !strcmp(psz_lang, "Italian") )
{
psz_short = "it";
}
else if ( !strcmp(psz_lang, "Japanese") )
{
psz_short = "ja";
}
else if ( !strcmp(psz_lang, "Dutch") )
{
psz_short = "nl";
}
else if ( !strcmp(psz_lang, "no") )
{
psz_short = "no";
}
else if ( !strcmp(psz_lang, "pl") )
{
psz_short = "pl";
}
else if ( !strcmp(psz_lang, "ru") )
{
psz_short = "ru";
}
else if ( !strcmp(psz_lang, "se") )
{
psz_short = "se";
}
else if ( !strcmp(psz_lang, "English") )
{
psz_short = "C";
}
if ( psz_short != NULL )
{
setenv("LANG", psz_short, 1);
return 1;
}
return 0;
}
void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
{
char i_dummy;
......@@ -53,6 +114,28 @@ void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
p_char++;
}
/* Check if $LANG is set. */
if ( (p_char = getenv("LANG")) == NULL )
{
/* Retrieve user's preferences. */
NSUserDefaults * p_defs =
[[NSUserDefaults standardUserDefaults] autorelease];
NSArray * p_languages =
[[p_defs objectForKey:@"AppleLanguages"] autorelease];
NSEnumerator * p_enumerator =
[[p_languages objectEnumerator] autorelease];
NSString * p_lang;
while ( (p_lang = [[p_enumerator nextObject] autorelease]) )
{
const char * psz_string = [p_lang lossyCString];
if ( FindLanguage( psz_string ) )
{
break;
}
}
}
}
/*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment