示例#1
0
void ReStream::AddChannelStream(char* rtspUrl,int CID, int DID, char* width,char* height, char* frameRate,char* bitrate, char * outputRtspUrl, bool isResize, int restreamID )
{
	try
	{
		if(isServerAttached){
			GstRTSPMediaFactory *factory;
			char desc[SIZEOFCHARARRAYBIGGER];
			char mountUrl[SIZEOFCHARARRAYBIGGER];

			factory = gst_rtsp_media_factory_new ();

			if( isResize )
				sprintf(desc,"( rtspsrc location=%s latency=0 retry=2 timeout=10000 tcp-timeout=100000 ! rtph264depay ! decodebin ! videoconvert ! videoscale ! video/x-raw,width=%s,height=%s ! videorate ! video/x-raw,framerate=%s/1 ! x264enc bitrate=%s ! rtph264pay name=pay0 pt=96 )", rtspUrl,width,height, frameRate, bitrate);
			else
				sprintf(desc,"( rtspsrc location=%s latency=0 retry=2 timeout=10000 tcp-timeout=100000 do-timestamp=true protocols=tcp ! rtph264depay ! rtph264pay name=pay0 pt=96 )",rtspUrl);

			gst_rtsp_media_factory_set_launch (factory,desc);

			g_signal_connect (factory, "media-configure", (GCallback) media_configure, NULL);
			g_signal_connect (server, "client-connected", (GCallback) client_connected, NULL);
			g_signal_connect (factory, "media-constructed", (GCallback) media_constructed, NULL);

			gst_rtsp_media_factory_set_shared (factory, TRUE);

			if(!isLocalStream ){
				if ( !isResize )
					sprintf(mountUrl,"/BroadCID%dDID%d",CID,DID);
				else
					sprintf(mountUrl,"/BroadCID%dDID%dRES%d",CID,DID,restreamID);
			}
			else{
				if ( !isResize )
					sprintf(mountUrl,"/localCID%dDID%d",CID,DID);
				else
					sprintf(mountUrl,"/localCID%dDID%dRES%d",CID,DID,restreamID);
			}
			gst_rtsp_mount_points_add_factory (mounts, mountUrl, factory);
			gst_rtsp_server_set_backlog (server, 10);
			if( isLocalStream ){
				sprintf( outputRtspUrl,"rtsp://%s:%s%s","127.0.0.1",portNo,mountUrl);
			}else{
				sprintf( outputRtspUrl,"rtsp://%s:%s%s",ipAddress,portNo,mountUrl);
			}
			if ( ISDEBUG ){
				cout<<"\nDesc---"<<outputRtspUrl<<endl;
				cout<<"Channel Add Successful\n";
		}
	}
		else{
			if ( ISDEBUG )
				cout<<"Server is Not Attached. Hence cannot add channel\n";
		}
	}
	catch(Exception &e){
		commclass.PrintException("ReStream","CV::AddChannelStream",e);
	}
	catch(exception &e){
		commclass.PrintException("ReStream","STD::AddChannelStream",e);
	}
}
示例#2
0
static void
gst_rtsp_server_set_property (GObject * object, guint propid,
    const GValue * value, GParamSpec * pspec)
{
  GstRTSPServer *server = GST_RTSP_SERVER (object);

  switch (propid) {
    case PROP_ADDRESS:
      gst_rtsp_server_set_address (server, g_value_get_string (value));
      break;
    case PROP_SERVICE:
      gst_rtsp_server_set_service (server, g_value_get_string (value));
      break;
    case PROP_BACKLOG:
      gst_rtsp_server_set_backlog (server, g_value_get_int (value));
      break;
    case PROP_SESSION_POOL:
      gst_rtsp_server_set_session_pool (server, g_value_get_object (value));
      break;
    case PROP_MEDIA_MAPPING:
      gst_rtsp_server_set_media_mapping (server, g_value_get_object (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
  }
}
示例#3
0
//void ReStream::AddVODStream(char* fileName,char * mountUrl, int CID, int DID, char* width,char* height, char* frameRate,char* bitrate, char * outputRtspUrl, bool isResize )
void ReStream::AddVODStream( char* fileName,char * mountUrl, char * outputRtspUrl )
{
	try
	{
		if(isServerAttached){
			GstRTSPMediaFactory *factory;
			char desc[SIZEOFCHARARRAYBIGGER];
			char localUrl[SIZEOFCHARARRAYBIGGER];

			factory = gst_rtsp_media_factory_new ();


			sprintf(desc,"( filesrc location=%s ! decodebin !  x264enc ! rtph264pay name=pay0 pt=96 )",fileName);

			gst_rtsp_media_factory_set_launch (factory,desc);

			gst_rtsp_media_factory_set_shared (factory, FALSE);


			cout<<"mountRl before = "<<mountUrl<<endl;
			sprintf(localUrl,"/%s",mountUrl);
			cout<<"mountRl after = "<<localUrl<<endl;

			gst_rtsp_mount_points_add_factory (mounts, localUrl, factory);
			gst_rtsp_server_set_backlog (server, 10);
			if( isLocalStream ){
				sprintf( outputRtspUrl,"rtsp://%s:%s%s","127.0.0.1",portNo,localUrl);
			}else{
				sprintf( outputRtspUrl,"rtsp://%s:%s%s",ipAddress,portNo,localUrl);
			}
			if ( ISDEBUG ){
				cout<<"\nVODDesc---"<<outputRtspUrl<<endl;
				cout<<"VOD Add Successful\n";
		}
	}
		else{
			if ( ISDEBUG )
				cout<<"Server is Not Attached. Hence cannot add channel\n";
		}
	}
	catch(Exception &e){
		commclass.PrintException("ReStream","CV::AddChannelStream",e);
	}
	catch(exception &e){
		commclass.PrintException("ReStream","STD::AddChannelStream",e);
	}
}