Commit b34c5cde authored by Ghislain MARY's avatar Ghislain MARY

Add API to get sent and received video size.

parent 2d30405a
......@@ -434,6 +434,21 @@ MS2_PUBLIC void video_stream_iterate(VideoStream *stream);
MS2_PUBLIC void video_stream_send_vfu(VideoStream *stream);
MS2_PUBLIC void video_stream_stop(VideoStream * stream);
MS2_PUBLIC void video_stream_set_sent_video_size(VideoStream *stream, MSVideoSize vsize);
/**
* Gets the size of the video that is sent.
* @param[in] stream The videostream for which to get the sent video size.
* @return The sent video size or MS_VIDEO_SIZE_UNKNOWN if not available.
*/
MS2_PUBLIC MSVideoSize video_stream_get_sent_video_size(VideoStream *stream);
/**
* Gets the size of the video that is received.
* @param[in] stream The videostream for which to get the received video size.
* @return The received video size or MS_VIDEO_SIZE_UNKNOWN if not available.
*/
MS2_PUBLIC MSVideoSize video_stream_get_received_video_size(VideoStream *stream);
MS2_PUBLIC void video_stream_enable_self_view(VideoStream *stream, bool_t val);
MS2_PUBLIC unsigned long video_stream_get_native_window_id(VideoStream *stream);
MS2_PUBLIC void video_stream_set_native_window_id(VideoStream *stream, unsigned long id);
......
......@@ -23,6 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <mediastreamer2/msfilter.h>
/* some global constants for video MSFilter(s) */
#define MS_VIDEO_SIZE_UNKNOWN_W 0
#define MS_VIDEO_SIZE_UNKNOWN_H 0
#define MS_VIDEO_SIZE_SQCIF_W 128
#define MS_VIDEO_SIZE_SQCIF_H 96
......@@ -133,6 +136,8 @@ typedef struct MSRect{
int x,y,w,h;
} MSRect;
#define MS_VIDEO_SIZE_UNKNOWN (MSVideoSize){ MS_VIDEO_SIZE_UNKNOWN_W, MS_VIDEO_SIZE_UNKNOWN_H }
#define MS_VIDEO_SIZE_CIF (MSVideoSize){MS_VIDEO_SIZE_CIF_W,MS_VIDEO_SIZE_CIF_H}
#define MS_VIDEO_SIZE_QCIF (MSVideoSize){MS_VIDEO_SIZE_QCIF_W,MS_VIDEO_SIZE_QCIF_H}
#define MS_VIDEO_SIZE_4CIF (MSVideoSize){MS_VIDEO_SIZE_4CIF_W,MS_VIDEO_SIZE_4CIF_H}
......
......@@ -288,8 +288,8 @@ static void dec_process(MSFilter *f){
if (got_picture) {
ms_queue_put(f->outputs[0],get_as_yuvmsg(f,d,&orig));
if (!d->first_image_decoded) {
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);
d->first_image_decoded = TRUE;
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);
}
}
p+=len;
......@@ -325,9 +325,22 @@ static int reset_first_image(MSFilter* f, void *data) {
return 0;
}
static int dec_get_vsize(MSFilter *f, void *data) {
DecData *d = (DecData *)f->data;
MSVideoSize *vsize = (MSVideoSize *)data;
if (d->first_image_decoded == TRUE) {
vsize->width = d->outbuf.w;
vsize->height = d->outbuf.h;
} else {
*vsize = MS_VIDEO_SIZE_UNKNOWN;
}
return 0;
}
static MSFilterMethod h264_dec_methods[]={
{ MS_FILTER_ADD_FMTP , dec_add_fmtp },
{ MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION, reset_first_image },
{ MS_FILTER_GET_VIDEO_SIZE, dec_get_vsize },
{ 0 , NULL }
};
......
......@@ -692,8 +692,8 @@ static void dec_process_frame(MSFilter *f, mblk_t *inm){
ms_queue_put(f->outputs[0],om);
if (!s->first_image_decoded) {
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);
s->first_image_decoded = TRUE;
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);
}
}
frame->b_rptr+=len;
......@@ -716,11 +716,23 @@ static int reset_first_image(MSFilter* f, void *data) {
return 0;
}
static int dec_get_vsize(MSFilter *f, void *data) {
DecState *s = (DecState *)f->data;
MSVideoSize *vsize = (MSVideoSize *)data;
if (s->first_image_decoded == TRUE) {
vsize->width = s->outbuf.w;
vsize->height = s->outbuf.h;
} else {
*vsize = MS_VIDEO_SIZE_UNKNOWN;
}
return 0;
}
static MSFilterMethod methods[]={
{ MS_FILTER_ADD_FMTP , dec_add_fmtp },
{ MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION, reset_first_image },
{ MS_FILTER_GET_VIDEO_SIZE, dec_get_vsize },
{ 0 , NULL }
};
......
......@@ -632,8 +632,8 @@ static void dec_process(MSFilter *f) {
ms_message("VP8 decoder: Frame size: %dx%d", s->yuv_width, s->yuv_height);
}
if (!s->first_image_decoded) {
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);
s->first_image_decoded = TRUE;
ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_FIRST_IMAGE_DECODED);
}
}
freemsg(m);
......@@ -647,8 +647,21 @@ static int reset_first_image(MSFilter* f, void *data) {
return 0;
}
static int dec_get_vsize(MSFilter *f, void *data) {
DecState *s = (DecState *)f->data;
MSVideoSize *vsize = (MSVideoSize *)data;
if (s->first_image_decoded == TRUE) {
vsize->width = s->yuv_width;
vsize->height = s->yuv_height;
} else {
*vsize = MS_VIDEO_SIZE_UNKNOWN;
}
return 0;
}
static MSFilterMethod dec_methods[]={
{ MS_VIDEO_DECODER_RESET_FIRST_IMAGE_NOTIFICATION, reset_first_image },
{ MS_FILTER_GET_VIDEO_SIZE, dec_get_vsize },
{ 0 , NULL }
};
......
......@@ -152,8 +152,7 @@ VideoStream *video_stream_new(int loc_rtp_port, int loc_rtcp_port, bool_t use_ip
stream->ms.rtpsend=ms_filter_new(MS_RTP_SEND_ID);
stream->ms.ice_check_list=NULL;
rtp_session_register_event_queue(stream->ms.session,stream->ms.evq);
stream->sent_vsize.width=MS_VIDEO_SIZE_CIF_W;
stream->sent_vsize.height=MS_VIDEO_SIZE_CIF_H;
stream->sent_vsize = MS_VIDEO_SIZE_CIF;
stream->dir=VideoStreamSendRecv;
stream->display_filter_auto_rotate_enabled=0;
stream->source_performs_encoding = FALSE;
......@@ -168,6 +167,22 @@ void video_stream_set_sent_video_size(VideoStream *stream, MSVideoSize vsize){
stream->sent_vsize=vsize;
}
MSVideoSize video_stream_get_sent_video_size(VideoStream *stream) {
MSVideoSize vsize = MS_VIDEO_SIZE_UNKNOWN;
if (stream->ms.encoder != NULL) {
ms_filter_call_method(stream->ms.encoder, MS_FILTER_GET_VIDEO_SIZE, &vsize);
}
return vsize;
}
MSVideoSize video_stream_get_received_video_size(VideoStream *stream) {
MSVideoSize vsize = MS_VIDEO_SIZE_UNKNOWN;
if (stream->ms.decoder != NULL) {
ms_filter_call_method(stream->ms.decoder, MS_FILTER_GET_VIDEO_SIZE, &vsize);
}
return vsize;
}
void video_stream_set_relay_session_id(VideoStream *stream, const char *id){
ms_filter_call_method(stream->ms.rtpsend, MS_RTP_SEND_SET_RELAY_SESSION_ID,(void*)id);
}
......@@ -716,8 +731,7 @@ int video_stream_get_camera_sensor_rotation(VideoStream *stream) {
VideoPreview * video_preview_new(void){
VideoPreview *stream = (VideoPreview *)ms_new0 (VideoPreview, 1);
stream->sent_vsize.width=MS_VIDEO_SIZE_CIF_W;
stream->sent_vsize.height=MS_VIDEO_SIZE_CIF_H;
stream->sent_vsize = MS_VIDEO_SIZE_CIF;
choose_display_name(stream);
return stream;
}
......
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