[Mplayer-cvslog] CVS: main asf.h,NONE,1.1 asf_streaming.c,NONE,1.1 network.c,NONE,1.1 url.c,NONE,1.1 url.h,NONE,1.1 Makefile,1.29,1.30 asfheader.c,1.11,1.12 demux_asf.c,1.6,1.7
Bertrand Baudet
bertrand at users.sourceforge.net
Fri May 18 18:14:08 CEST 2001
- Previous message: [Mplayer-cvslog] CVS: main/DOCS DGA,1.1,1.2
- Next message: [Mplayer-cvslog] CVS: main/DOCS/Hungarian BUGREPORTS,1.2,1.3 CDROM,1.1,1.2 CODECS,1.2,1.3 DVD,1.2,1.3 DVD-FAQ,1.2,1.3 INSTALL,1.1,1.2 LIRC,1.1,1.2 MPlayer-FAQ,1.7,1.8 MTRR,1.1,1.2 OpenDivX,1.1,1.2 README,1.3,1.4 SOUNDCARDS,1.2,1.3 TVout-G400,1.1,1.2 Translator,1.2,1.3 VIDEOCARDS,1.3,1.4 example.conf,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv12373
Modified Files:
Makefile asfheader.c demux_asf.c
Added Files:
asf.h asf_streaming.c network.c url.c url.h
Log Message:
Starting implementation of ASF network streaming.
--- NEW FILE ---
#ifndef ASF_H
#define ASF_H
#include <inttypes.h>
///////////////////////
// MS GUID definition
///////////////////////
#ifndef GUID_DEFINED
#define GUID_DEFINED
// Size of GUID is 16 bytes!
typedef struct __attribute__((packed)) {
uint32_t Data1; // 4 bytes
uint16_t Data2; // 2 bytes
uint16_t Data3; // 2 bytes
uint8_t Data4[8]; // 8 bytes
} GUID_t;
#endif
///////////////////////
// ASF Object Header
///////////////////////
typedef struct __attribute__((packed)) {
uint8_t guid[16];
uint64_t size;
} ASF_obj_header_t;
////////////////
// ASF Header
////////////////
typedef struct __attribute__((packed)) {
ASF_obj_header_t objh;
uint32_t cno; // number of subchunks
uint8_t v1; // unknown (0x01)
uint8_t v2; // unknown (0x02)
} ASF_header_t;
/////////////////////
// ASF File Header
/////////////////////
typedef struct __attribute__((packed)) {
uint8_t client[16]; // Client GUID
uint64_t file_size;
uint64_t creat_time; //File creation time FILETIME 8
uint64_t packets; //Number of packets UINT64 8
uint64_t end_timestamp; //Timestamp of the end position UINT64 8
uint64_t duration; //Duration of the playback UINT64 8
uint32_t start_timestamp; //Timestamp of the start position UINT32 4
uint32_t unk1; //Unknown, maybe reserved ( usually contains 0 ) UINT32 4
uint32_t flags; //Unknown, maybe flags ( usually contains 2 ) UINT32 4
uint32_t packetsize; //Size of packet, in bytes UINT32 4
uint32_t packetsize2; //Size of packet ( confirm ) UINT32 4
uint32_t frame_size; //Size of uncompressed video frame UINT32 4
} ASF_file_header_t;
///////////////////////
// ASF Stream Header
///////////////////////
typedef struct __attribute__((packed)) {
uint8_t type[16]; // Stream type (audio/video) GUID 16
uint8_t concealment[16]; // Audio error concealment type GUID 16
uint64_t unk1; // Unknown, maybe reserved ( usually contains 0 ) UINT64 8
uint32_t type_size; //Total size of type-specific data UINT32 4
uint32_t stream_size; //Size of stream-specific data UINT32 4
uint16_t stream_no; //Stream number UINT16 2
uint32_t unk2; //Unknown UINT32 4
} ASF_stream_header_t;
///////////////////////////
// ASF Content Description
///////////////////////////
typedef struct __attribute__((packed)) {
uint16_t title_size;
uint16_t author_size;
uint16_t copyright_size;
uint16_t comment_size;
uint16_t rating_size;
} ASF_content_description_t;
////////////////////////
// ASF Segment Header
////////////////////////
typedef struct __attribute__((packed)) {
uint8_t streamno;
uint8_t seq;
uint32_t x;
uint8_t flag;
} ASF_segmhdr_t;
//////////////////////
// ASF Stream Chunck
//////////////////////
typedef struct __attribute__((packed)) {
uint16_t type;
uint16_t length;
uint32_t sequence_number;
uint16_t unknown;
uint16_t length2;
} ASF_stream_chunck_t;
// Definition of the differents type of ASF streaming
typedef enum {
ASF_Unknown_e,
ASF_Live_e,
ASF_Prerecorded_e,
ASF_Redirector_e
} ASF_StreamType_e;
#endif
--- NEW FILE ---
#include "asf.h"
#include <string.h>
static ASF_StreamType_e stream_type;
void asf_streaming(char *data, int length) {
ASF_stream_chunck_t *stream_chunck=(ASF_stream_chunck_t*)data;
printf("ASF stream chunck size=%d\n", stream_chunck->length);
switch(stream_chunck->type) {
case 0x4324: // Clear ASF configuration
printf(" --> Clearing ASF stream configuration!\n");
break;
case 0x4424: // Data follows
printf(" --> Data follows\n");
break;
case 0x4524: // Transfer complete
printf(" --> Transfer complete\n");
break;
case 0x4824: // ASF header chunk follows
printf(" --> ASF header chunk follows\n");
break;
default:
printf("======> Unknown stream type %d\n", stream_chunck->type );
}
}
void asf_steam_type(char *content_type, char *features) {
stream_type = ASF_Unknown_e;
if( !strcasecmp(content_type, "application/octet-stream") ) {
if( strstr(features, "broadcast")) {
printf("-----> Live stream <-------\n");
stream_type = ASF_Live_e;
} else {
printf("-----> Prerecorded <-------\n");
stream_type = ASF_Prerecorded_e;
}
} else {
if( (!strcasecmp(content_type, "audio/x-ms-wax")) ||
(!strcasecmp(content_type, "audio/x-ms-wma")) ||
(!strcasecmp(content_type, "video/x-ms-asf")) ||
(!strcasecmp(content_type, "video/x-ms-afs")) ||
(!strcasecmp(content_type, "video/x-ms-wvx")) ||
(!strcasecmp(content_type, "video/x-ms-wmv")) ||
(!strcasecmp(content_type, "video/x-ms-wma")) ) {
printf("-----> Redirector <-------\n");
stream_type = ASF_Redirector_e;
} else {
printf("-----> unknown content-type: %s\n", content_type );
stream_type = ASF_Unknown_e;
}
}
}
--- NEW FILE ---
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
int
connect2Server(char *host, int port) {
int socket_server_fd;
struct sockaddr_in server_address;
printf(">>>> connect2Server [%s@%d]\n", host, port );
socket_server_fd = socket(AF_INET, SOCK_STREAM, 0);
if( socket_server_fd==-1 ) {
perror("Failed to create socket");
exit(1);
}
if( isalpha(host[0]) ) {
struct hostent *hp;
if( (hp=gethostbyname( host ))==NULL ) {
printf("Unknown host: %s\n", host);
exit(1);
}
memcpy( &server_address.sin_addr.s_addr, hp->h_addr, hp->h_length );
} else {
inet_pton(AF_INET, host, &server_address.sin_addr);
}
server_address.sin_family=AF_INET;
server_address.sin_port=htons(port);
if( connect( socket_server_fd, (struct sockaddr*)&server_address, sizeof(server_address) )==-1 ) {
perror("Failed to connect to server");
close(socket_Stream_fd);
exit(1);
}
return socket_server_fd;
}
--- NEW FILE ---
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "url.h"
URL_t*
set_url(char* url) {
int pos1, pos2;
URL_t* Curl;
char *ptr1, *ptr2;
// Create the URL container
Curl = (URL_t*)malloc(sizeof(URL_t));
if( Curl==NULL ) {
printf("Memory allocation failed!\n");
exit(1);
}
// Copy the url in the URL container
Curl->url = (char*)malloc(strlen(url)+1);
if( Curl->url==NULL ) {
printf("Memory allocation failed!\n");
exit(1);
}
strcpy(Curl->url, url);
// extract the protocol
ptr1 = strstr(url, "://");
if( ptr1==NULL ) {
printf("Malformed URL!\n");
return NULL;
}
pos1 = ptr1-url;
Curl->protocol = (char*)malloc(pos1+1);
strncpy(Curl->protocol, url, pos1);
Curl->protocol[pos1] = '\0';
// look if the port is given
ptr2 = strstr(ptr1+3, ":");
if( ptr2==NULL ) {
// No port is given
// Look if a path is given
ptr2 = strstr(ptr1+3, "/");
if( ptr2==NULL ) {
// No path/filename
// So we have an URL like http://www.hostname.com
pos2 = strlen(url);
} else {
// We have an URL like http://www.hostname.com/file.txt
pos2 = ptr2-url;
}
} else {
// We have an URL beginning like http://www.hostname.com:1212
// Get the port number
Curl->port = atoi(ptr2+1);
pos2 = ptr2-url;
}
// copy the hostname in the URL container
Curl->hostname = (char*)malloc(strlen(url)+1);
if( Curl->hostname==NULL ) {
printf("Memory allocation failed!\n");
exit(1);
}
strncpy(Curl->hostname, ptr1+3, pos2-pos1-3);
// Look if a path is given
ptr2 = strstr(ptr1+3, "/");
if( ptr2!=NULL ) {
// A path/filename is given
// check if it's not a trailing '/'
if( strlen(ptr2)>1 ) {
// copy the path/filename in the URL container
Curl->path = (char*)malloc(strlen(ptr2));
if( Curl->path==NULL ) {
printf("Memory allocation failed!\n");
exit(1);
}
strcpy(Curl->path, ptr2+1);
}
}
return Curl;
}
void
free_url(URL_t* url) {
if(url) return;
if(url->url) free(url->url);
if(url->protocol) free(url->protocol);
if(url->hostname) free(url->hostname);
if(url->path) free(url->path);
free(url);
}
--- NEW FILE ---
#ifndef URL_H
#define URL_H
typedef struct {
char *url;
char *protocol;
char *hostname;
char *path;
unsigned int port;
} URL_t;
URL_t* set_url(char* url);
void free_url(URL_t* url);
#endif
Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** Makefile 2001/05/08 21:47:51 1.29
--- Makefile 2001/05/18 16:14:06 1.30
***************
*** 21,26 ****
BINDIR = ${prefix}/bin
# BINDIR = /usr/local/bin
! SRCS = find_sub.c aviprint.c dll_init.c dec_audio.c aviwrite.c aviheader.c asfheader.c demux_avi.c demux_asf.c demux_mpg.c demuxer.c stream.c codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c mixer.c dvdauth.c spudec.c
! OBJS = find_sub.o aviprint.o dll_init.o dec_audio.o aviwrite.o aviheader.o asfheader.o demux_avi.o demux_asf.o demux_mpg.o demuxer.o stream.o codec-cfg.o subreader.o linux/getch2.o linux/timer-lx.o linux/shmem.o xa/xa_gsm.o lirc_mp.o cfgparser.o mixer.o dvdauth.o spudec.o
CFLAGS = $(OPTFLAGS) -Iloader -Ilibvo $(CSS_INC) # -Wall
A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3
--- 21,28 ----
BINDIR = ${prefix}/bin
# BINDIR = /usr/local/bin
! SRCS = asf_streaming.c find_sub.c aviprint.c dll_init.c dec_audio.c aviwrite.c aviheader.c asfheader.c demux_avi.c demux_asf.c demux_mpg.c demuxer.c stream.c codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c mixer.c dvdauth.c spudec.c
! #BB: IMHO It's simplier to use the following rule:
! #OBJS = $(SRCS:.c=.o)
! OBJS = asf_streaming.o find_sub.o aviprint.o dll_init.o dec_audio.o aviwrite.o aviheader.o asfheader.o demux_avi.o demux_asf.o demux_mpg.o demuxer.o stream.o codec-cfg.o subreader.o linux/getch2.o linux/timer-lx.o linux/shmem.o xa/xa_gsm.o lirc_mp.o cfgparser.o mixer.o dvdauth.o spudec.o
CFLAGS = $(OPTFLAGS) -Iloader -Ilibvo $(CSS_INC) # -Wall
A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3
Index: asfheader.c
===================================================================
RCS file: /cvsroot/mplayer/main/asfheader.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** asfheader.c 2001/05/16 23:40:55 1.11
--- asfheader.c 2001/05/18 16:14:06 1.12
***************
*** 17,20 ****
--- 17,24 ----
#include "stheader.h"
+ #include "asf.h"
+
+ // BB: Moved to asf.h --------------------- FROM HERE -------------------
+ #ifdef 0
typedef struct __attribute__((packed)) {
unsigned char guid[16];
***************
*** 61,64 ****
--- 65,70 ----
unsigned short rating_size;
} ASF_content_description_t;
+ #endif
+ // BB: Moved to asf.h --------------------- TO HERE -------------------
static ASF_header_t asfh;
***************
*** 76,86 ****
//int i;
! void print_asf_string(const char* name, char* string, int length){
! int i;
! printf("%s", name);
! for(i=0;i<length && string[i]!='\0';i+=2){
! printf("%c", string[i]);
}
! printf("\n");
}
--- 82,98 ----
//int i;
! // the variable string is modify in this function
! void pack_asf_string(char* string, int length) {
! int i,j;
! for( i=0, j=0; i<length && string[i]!='\0'; i+=2, j++) {
! string[j]=string[i];
}
! string[j]='\0';
! }
!
! // the variable string is modify in this function
! void print_asf_string(const char* name, char* string, int length) {
! pack_asf_string(string, length);
! printf("%s%s\n", name, string);
}
Index: demux_asf.c
===================================================================
RCS file: /cvsroot/mplayer/main/demux_asf.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** demux_asf.c 2001/04/23 22:33:06 1.6
--- demux_asf.c 2001/05/18 16:14:06 1.7
***************
*** 9,12 ****
--- 9,14 ----
#include "demuxer.h"
+ #include "asf.h"
+
// defined at asfheader.c:
extern unsigned char* asf_packet;
***************
*** 25,28 ****
--- 27,32 ----
//static int skip_video_frames=0;
+ //BB: Moved to asf.h --------- FROM HERE --------
+ #ifdef 0
typedef struct __attribute__((packed)) {
unsigned char streamno;
***************
*** 31,34 ****
--- 35,40 ----
unsigned char flag;
} ASF_segmhdr_t;
+ #endif
+ //BB: Moved to asf.h --------- TO HERE --------
static void asf_descrambling(unsigned char *src,int len){
_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog
- Previous message: [Mplayer-cvslog] CVS: main/DOCS DGA,1.1,1.2
- Next message: [Mplayer-cvslog] CVS: main/DOCS/Hungarian BUGREPORTS,1.2,1.3 CDROM,1.1,1.2 CODECS,1.2,1.3 DVD,1.2,1.3 DVD-FAQ,1.2,1.3 INSTALL,1.1,1.2 LIRC,1.1,1.2 MPlayer-FAQ,1.7,1.8 MTRR,1.1,1.2 OpenDivX,1.1,1.2 README,1.3,1.4 SOUNDCARDS,1.2,1.3 TVout-G400,1.1,1.2 Translator,1.2,1.3 VIDEOCARDS,1.3,1.4 example.conf,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the MPlayer-cvslog
mailing list