LIVE STREAMING
Posted: 21 Apr 2009 07:49
Hi All,
Iam trying to send a video data to play it in Vlc player , for this i have used a simple scoket comuncation ,
i could able to invoke VLC player but could not able to send data to player via scoket , could any body guide me
regarding the same .
#include <stdio.h> /* for printf(), fprintf() */
#include <winsock.h> /* for socket(),... */
#include <stdlib.h> /* for exit() */
#include <windows.h>
#include <shellapi.h>
#include <shlwapi.h>
#include <wininet.h>
#include <strsafe.h>
#pragma comment (lib, "ws2_32.lib")
#pragma comment(lib,"shell32.lib")
#define WIN32_LEAN_AND_MEAN
#define MAXPENDING 1 /* Maximum outstanding connection requests */
void DieWithError(char *errorMessage); /* Error handling function */
void HandleTCPClient(int clntSocket); /* TCP client handling function */
void main(int argc, char *argv[])
{
int servSock; /* Socket descriptor for server */
int clntSock; /* Socket descriptor for client */
struct sockaddr_in echoServAddr; /* Local address */
struct sockaddr_in echoClntAddr; /* Client address */
unsigned short echoServPort; /* Server port */
unsigned int clntLen; /* Length of client address data structure */
WSADATA wsaData; /* Structure for WinSock setup communication */
char socketname[60];
int val;
char *echoBuffer;
argv[1]="1234";
argc=2;
if (argc != 2) /* Test for correct number of arguments */
{
fprintf(stderr, "Usage: %s <Server Port>\n", argv[0]);
exit(1);
}
echoServPort = atoi(argv[1]); /* first arg: Local port */
if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) /* Load Winsock 2.0 DLL */
{
fprintf(stderr, "WSAStartup() failed");
exit(1);
}
/* Create socket for incoming connections */
if ((servSock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
DieWithError("socket() failed");
/* Construct local address structure */
memset(&echoServAddr, 0, sizeof(echoServAddr)); /* Zero out structure */
echoServAddr.sin_family = AF_INET; /* Internet address family */
echoServAddr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */
echoServAddr.sin_port = htons(echoServPort); /* Local port */
/* Bind to the local address */
if (bind(servSock, (struct sockaddr *) &echoServAddr, sizeof(echoServAddr)) < 0)
DieWithError("bind() failed");
/* Mark the socket so it will listen for incoming connections */
if (listen(servSock, MAXPENDING) < 0)
DieWithError("listen() failed");
sprintf ( socketname, "http://127.0.0.1:%d", 1234 );
val=(int)ShellExecute(0,"open","C:\\Program Files\\VideoLAN\\VLC\\vlc.exe",socketname,0,SW_SHOWDEFAULT);
val=GetLastError();
// for (;;) /* Run forever */
{
/* Set the size of the in-out parameter */
clntLen = sizeof(echoClntAddr);
// if ((clntSock = accept(servSock, NULL, NULL)) < 0)
if ((clntSock = accept(servSock, (struct sockaddr *) &echoClntAddr, &clntLen)) < 0)
DieWithError("accept() failed");
fp=fopen("image.JPG","rb"); /// image data to be dipalyed in VLC player
fseek(fp,0,SEEK_END);
length=ftell(fp);
fseek(fp,0,SEEK_SET);
echoBuffer=(char *) calloc(length,1);
fread(echoBuffer,length,1,fp);
recvMsgSize=length;
if (send(clntSocket, echoBuffer, recvMsgSize, 0) != recvMsgSize)
DieWithError("send() failed");
}
}
Iam trying to send a video data to play it in Vlc player , for this i have used a simple scoket comuncation ,
i could able to invoke VLC player but could not able to send data to player via scoket , could any body guide me
regarding the same .
#include <stdio.h> /* for printf(), fprintf() */
#include <winsock.h> /* for socket(),... */
#include <stdlib.h> /* for exit() */
#include <windows.h>
#include <shellapi.h>
#include <shlwapi.h>
#include <wininet.h>
#include <strsafe.h>
#pragma comment (lib, "ws2_32.lib")
#pragma comment(lib,"shell32.lib")
#define WIN32_LEAN_AND_MEAN
#define MAXPENDING 1 /* Maximum outstanding connection requests */
void DieWithError(char *errorMessage); /* Error handling function */
void HandleTCPClient(int clntSocket); /* TCP client handling function */
void main(int argc, char *argv[])
{
int servSock; /* Socket descriptor for server */
int clntSock; /* Socket descriptor for client */
struct sockaddr_in echoServAddr; /* Local address */
struct sockaddr_in echoClntAddr; /* Client address */
unsigned short echoServPort; /* Server port */
unsigned int clntLen; /* Length of client address data structure */
WSADATA wsaData; /* Structure for WinSock setup communication */
char socketname[60];
int val;
char *echoBuffer;
argv[1]="1234";
argc=2;
if (argc != 2) /* Test for correct number of arguments */
{
fprintf(stderr, "Usage: %s <Server Port>\n", argv[0]);
exit(1);
}
echoServPort = atoi(argv[1]); /* first arg: Local port */
if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) /* Load Winsock 2.0 DLL */
{
fprintf(stderr, "WSAStartup() failed");
exit(1);
}
/* Create socket for incoming connections */
if ((servSock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
DieWithError("socket() failed");
/* Construct local address structure */
memset(&echoServAddr, 0, sizeof(echoServAddr)); /* Zero out structure */
echoServAddr.sin_family = AF_INET; /* Internet address family */
echoServAddr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */
echoServAddr.sin_port = htons(echoServPort); /* Local port */
/* Bind to the local address */
if (bind(servSock, (struct sockaddr *) &echoServAddr, sizeof(echoServAddr)) < 0)
DieWithError("bind() failed");
/* Mark the socket so it will listen for incoming connections */
if (listen(servSock, MAXPENDING) < 0)
DieWithError("listen() failed");
sprintf ( socketname, "http://127.0.0.1:%d", 1234 );
val=(int)ShellExecute(0,"open","C:\\Program Files\\VideoLAN\\VLC\\vlc.exe",socketname,0,SW_SHOWDEFAULT);
val=GetLastError();
// for (;;) /* Run forever */
{
/* Set the size of the in-out parameter */
clntLen = sizeof(echoClntAddr);
// if ((clntSock = accept(servSock, NULL, NULL)) < 0)
if ((clntSock = accept(servSock, (struct sockaddr *) &echoClntAddr, &clntLen)) < 0)
DieWithError("accept() failed");
fp=fopen("image.JPG","rb"); /// image data to be dipalyed in VLC player
fseek(fp,0,SEEK_END);
length=ftell(fp);
fseek(fp,0,SEEK_SET);
echoBuffer=(char *) calloc(length,1);
fread(echoBuffer,length,1,fp);
recvMsgSize=length;
if (send(clntSocket, echoBuffer, recvMsgSize, 0) != recvMsgSize)
DieWithError("send() failed");
}
}