Commit 72f307d7 authored by Pierre-Eric Pelloux-Prayer's avatar Pierre-Eric Pelloux-Prayer
Browse files

video: add parameter to display filter to control internal rotation of video

Internal = done by the filter
External = done by the view (e.g UIView for iOS) system
parent 55a90c37
......@@ -288,6 +288,7 @@ struct _VideoStream
bool_t use_preview_window;
bool_t use_rc;
bool_t pad[2];
bool_t display_filter_auto_rotate_enabled;
int device_orientation; /* warning: meaning of this variable depends on the platform (Android, iOS, ...) */
OrtpZrtpContext *ortpZrtpContext;
srtp_t srtp_session;
......@@ -341,6 +342,8 @@ MS2_PUBLIC void video_stream_enable_zrtp(VideoStream *vstream, AudioStream *astr
/* enable SRTP on the video stream */
MS2_PUBLIC bool_t video_stream_enable_strp(VideoStream* stream, enum ortp_srtp_crypto_suite_t suite, const char* snd_key, const char* rcv_key);
/* if enabled, the display filter will internaly rotate the video, according to the device orientation */
MS2_PUBLIC void video_stream_enable_display_filter_auto_rotate(VideoStream* stream, bool_t enable);
/**
* Small API to display a local preview window.
......
......@@ -58,6 +58,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MS_VIDEO_DISPLAY_SHOW_VIDEO \
MS_FILTER_METHOD(MSFilterVideoDisplayInterface,9,int)
/**Specifiy device orientation from portrait */
#define MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION \
MS_FILTER_METHOD(MSFilterVideoDisplayInterface,10,int)
/**
* Interface definitions for players
......
......@@ -39,6 +39,7 @@
id displayLink;
BOOL animating;
int deviceRotation;
int allocatedW, allocatedH;
}
......
......@@ -91,6 +91,7 @@
glInitDone = FALSE;
allocatedW = allocatedH = 0;
deviceRotation = 0;
}
- (void) drawView:(id)sender
......@@ -106,16 +107,18 @@
}
glBindFramebuffer(GL_FRAMEBUFFER, defaultFrameBuffer);
/*
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
int angle = 0;
if (orientation == UIInterfaceOrientationLandscapeRight)
angle = 270;
else if (orientation == UIInterfaceOrientationLandscapeLeft)
angle = 90;
*/
if (!glInitDone) {
glClear(GL_COLOR_BUFFER_BIT);
} else {
ogl_display_render(helper, angle);
ogl_display_render(helper, deviceRotation);
}
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderBuffer);
......@@ -261,10 +264,19 @@ static int iosdisplay_get_native_window(MSFilter *f, void *arg) {
return 0;
}
static int iosdisplay_set_device_orientation(MSFilter* f, void* arg) {
IOSDisplay* thiz=(IOSDisplay*)f->data;
if (!thiz)
return;
thiz->deviceRotation = *((int*)arg);
return 0;
}
static MSFilterMethod iosdisplay_methods[]={
{ MS_VIDEO_DISPLAY_SET_NATIVE_WINDOW_ID , iosdisplay_set_native_window },
{ MS_VIDEO_DISPLAY_GET_NATIVE_WINDOW_ID , iosdisplay_get_native_window },
{ MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION, iosdisplay_set_device_orientation },
{ 0, NULL}
};
@end
......
......@@ -291,7 +291,8 @@ static void configure_video_source(VideoStream *stream){
/* transmit orientation to source filter */
ms_filter_call_method(stream->source,MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION,&stream->device_orientation);
/* transmit its preview window id if any to source filter*/
/* transmit its preview window id if any to source filter*/
if (stream->preview_window_id!=0){
video_stream_set_native_preview_window_id(stream, stream->preview_window_id);
}
......@@ -471,7 +472,9 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
if (stream->window_id!=0){
ms_filter_call_method(stream->output, MS_VIDEO_DISPLAY_SET_NATIVE_WINDOW_ID,&stream->window_id);
}
if (stream->display_filter_auto_rotate_enabled) {
ms_filter_call_method(stream->output,MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION,&stream->device_orientation);
}
/* and connect the filters */
ms_connection_helper_start (&ch);
ms_connection_helper_link (&ch,stream->rtprecv,-1,0);
......@@ -647,6 +650,9 @@ void video_stream_set_device_rotation(VideoStream *stream, int orientation){
if (target_filter){
ms_filter_call_method(target_filter,MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION,&orientation);
}
if (stream->output && stream->display_filter_auto_rotate_enabled) {
ms_filter_call_method(stream->output,MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION,&orientation);
}
}
VideoPreview * video_preview_new(void){
......@@ -769,3 +775,7 @@ bool_t video_stream_enable_strp(VideoStream* stream, enum ortp_srtp_crypto_suite
return TRUE;
}
void video_stream_enable_display_filter_auto_rotate(VideoStream* stream, bool_t enable) {
stream->display_filter_auto_rotate_enabled = enable;
}
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