Tuesday 15 April 2014

android - Can the gstreamer play the media content which sended using this client code below? -



android - Can the gstreamer play the media content which sended using this client code below? -

i want write client server application stream media content pc (linux) android. client side code have decided write using posix sockets. on sever side (on android device) think utilize gstreamer api. client code shown below in listing interested in question, can gstreamer play media content sended using client code ?

#include <arpa/inet.h> #include <iostream> #include <netdb.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <unistd.h> int main(int argc, char** argv) { if(argc < 2) { std::cout << "\nerror: missing parameter" << std::endl; std::cout << "usage:\n\tmain <file path>\n" << std::endl; exit(0); } int len = strlen(argv[1]); char* file_name = new char[len]; file_name = argv[1]; file* file = fopen(file_name, "rb"); if (file == null) { std::cout << "error: cannot open file given path" << std::endl; fclose (file); } char buf[portion]; bzero((void*)buf, portion); int quantum = 0; sockaddr_in serveraddr, clientaddr; int sockfd = socket(af_inet, sock_stream, 0); serveraddr.sin_family = af_inet; serveraddr.sin_port = htons(2000); serveraddr.sin_addr.s_addr = inet_addr("127.0.0.1"); connect(sockfd, (struct sockaddr*)&serveraddr, sizeof(serveraddr)); bzero((void*)buf, portion); int bytes_read = 0; while( (bytes_read = fread(buf, 1, 8192, file) ) > 0) { int s = send(sockfd, buf, bytes_read, 0); bzero((void*)buf, portion); if (s == -1) { std::cout << "error: info connot sended" << std::endl; } std::cout << " . "; } std::cout << "done" << std::endl; homecoming 0; }

among many other things can utilize tcpserversrc host=127.0.0.1 , port=2000. create source element hear tcp connection on port 2000 of 127.0.0.1 , pass info gstreamer pipeline.

android c++ linux sockets gstreamer

No comments:

Post a Comment