|
From: | 武强 |
Subject: | Re: [Linphone-developers] Need Help for streaming RTP - iOS |
Date: | Wed, 30 Nov 2016 08:53:40 +0800 (CST) |
hi,
These code could be a demo to streaming video over rtp..
V4L2---->H264---->RTP PACKET--->NET
You can use ffplay or vlc to decode and dispaly the stream.
SDP:
m=video 6060 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; profile-level-id=64001E;
#include "mediastreamer2/mediastream.h"
#include "mediastreamer2/mseventqueue.h"
#include <signal.h>
static int active = 1;
/*handler called when pressing C-c*/
static void stop_handler(int signum){
active--;
if (active<0) {
ms_error("Brutal exit (%d)\n", active);
exit(-1);
}
}
const int payload_type_number = 96;
int main(int argc, char *argv[]){
const char *ip;
int remote_port = 6060;
int local_port = 6050;
MSWebCam *mWebCam = NULL;
VideoStream *stream;
RtpProfile *profile;
PayloadType *pt;
OrtpEvQueue *q = NULL;
RtpSession *session = NULL;
int err;
ortp_init();
ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
ms_init();
q = ortp_ev_queue_new();
ip = "127.0.0.1";
//ip = "172.16.14.129";
if(argc > 1)
{
local_port = atoi(argv[1]);
}
/*set a signal handler to interrupt the program cleanly*/
signal(SIGINT,stop_handler);
/*create the video stream */
stream = video_stream_new(local_port, local_port+1, FALSE);
video_stream_set_fps(stream,25.0);
video_stream_set_sent_video_size(stream, MS_VIDEO_SIZE_VGA);
//stream->dir = MediaStreamRecvOnly;
mWebCam = ms_web_cam_manager_get_cam(ms_web_cam_manager_get(),"V4L2: /dev/video1");
profile = "" RTP profile");
pt = payload_type_clone(&payload_type_h264);
rtp_profile_set_payload(profile, payload_type_number, pt);
/*set a target IP bitrate in bits/second */
media_stream_set_target_network_bitrate(&stream->ms, 8*1024*20);
/*video_stream_set_native_window_id(stream, (void*)-1);*/
err = video_stream_start(stream, profile, ip, remote_port, ip, remote_port+1, payload_type_number, 0, mWebCam);
if (err !=0 ){
fprintf(stderr,"Could not start video stream.");
goto end;
}
session = video_stream_get_rtp_session(stream);
rtp_session_register_event_queue(session, q);
/*program's main loop*/
while (active)
{
/*handle video stream background activity. This is non blocking*/
video_stream_iterate(stream);
/*pause 50ms to avoid busy loop*/
ms_usleep(50000);
}
end:
/*stop and destroy the video stream object*/
if (stream) video_stream_stop(stream);
/*free the RTP profile and payload type inside*/
if (profile) rtp_profile_destroy(profile);
return err;
}
From: "Sreejith N <address@hidden>"
To: "linphone-developers <address@hidden>"
CC:
Sent: 2016-11-29 14:50
Subject: [Linphone-developers] Need Help for streaming RTP - iOS
_______________________________________________
Linphone-developers mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/linphone-developers
[Prev in Thread] | Current Thread | [Next in Thread] |