Commit e3fe3eb2 authored by Simon Morlat's avatar Simon Morlat

allow updating of the video stream sending side

parent 3bdc6245
......@@ -198,6 +198,7 @@ struct _VideoStream
unsigned long window_id;
unsigned long preview_window_id;
VideoStreamDir dir;
MSWebCam *cam;
bool_t use_preview_window;
bool_t adapt_bitrate;
};
......@@ -218,6 +219,9 @@ int video_stream_start(VideoStream * stream, RtpProfile *profile, const char *re
void video_stream_set_relay_session_id(VideoStream *stream, const char *relay_session_id);
void video_stream_set_rtcp_information(VideoStream *st, const char *cname, const char *tool);
void video_stream_change_camera(VideoStream *stream, MSWebCam *cam);
/* Calling video_stream_set_sent_video_size() or changing the bitrate value in the used PayloadType during a stream is running does nothing.
The following function allows to take into account new parameters by redrawing the sending graph*/
void video_stream_update_video_params(VideoStream *stream);
/*function to call periodically to handle various events */
void video_stream_iterate(VideoStream *stream);
void video_stream_send_vfu(VideoStream *stream);
......@@ -238,6 +242,11 @@ int video_stream_send_only_start(VideoStream *videostream,
void video_stream_recv_only_stop(VideoStream *vs);
void video_stream_send_only_stop(VideoStream *vs);
/**
* Small API to display a local preview window.
**/
typedef VideoStream VideoPreview;
VideoPreview * video_preview_new();
......
......@@ -89,6 +89,10 @@ static void dec_snow_init(MSFilter *f){
static void dec_uninit(MSFilter *f){
DecState *s=(DecState*)f->data;
if (s->av_context.codec!=NULL){
avcodec_close(&s->av_context);
s->av_context.codec=NULL;
}
if (s->input!=NULL) freemsg(s->input);
if (s->yuv_msg!=NULL) freemsg(s->yuv_msg);
if (s->sws_ctx!=NULL){
......@@ -121,23 +125,21 @@ static int dec_add_fmtp(MSFilter *f, void *data){
static void dec_preprocess(MSFilter *f){
DecState *s=(DecState*)f->data;
int error;
/* we must know picture size before initializing snow decoder*/
if (s->codec!=CODEC_ID_SNOW){
error=avcodec_open(&s->av_context, s->av_codec);
if (error!=0) ms_error("avcodec_open() failed: %i",error);
if (s->codec==CODEC_ID_MPEG4 && s->dci_size>0){
s->av_context.extradata=s->dci;
s->av_context.extradata_size=s->dci_size;
if (s->av_context.codec==NULL){
/* we must know picture size before initializing snow decoder*/
if (s->codec!=CODEC_ID_SNOW){
error=avcodec_open(&s->av_context, s->av_codec);
if (error!=0) ms_error("avcodec_open() failed: %i",error);
if (s->codec==CODEC_ID_MPEG4 && s->dci_size>0){
s->av_context.extradata=s->dci;
s->av_context.extradata_size=s->dci_size;
}
}
}
}
static void dec_postprocess(MSFilter *f){
DecState *s=(DecState*)f->data;
if (s->av_context.codec!=NULL){
avcodec_close(&s->av_context);
s->av_context.codec=NULL;
}
}
static mblk_t * skip_rfc2190_header(mblk_t *inm){
......
......@@ -333,6 +333,7 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
return -1;
}
/* creates the filters */
stream->cam=cam;
stream->source = ms_web_cam_create_reader(cam);
stream->tee = ms_filter_new(MS_TEE_ID);
......@@ -434,6 +435,11 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
return 0;
}
void video_stream_update_video_params(VideoStream *stream){
/*calling video_stream_change_camera() does the job of unplumbing/replumbing and configuring the new graph*/
video_stream_change_camera(stream,stream->cam);
}
void video_stream_change_camera(VideoStream *stream, MSWebCam *cam){
if (stream->ticker && stream->source){
ms_ticker_detach(stream->ticker,stream->source);
......@@ -448,6 +454,7 @@ void video_stream_change_camera(VideoStream *stream, MSWebCam *cam){
/*re create new ones and configure them*/
stream->source = ms_web_cam_create_reader(cam);
stream->cam=cam;
configure_video_source(stream);
ms_filter_link (stream->source, 0, stream->pixconv, 0);
ms_filter_link (stream->pixconv, 0, stream->sizeconv, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment