video_x11_channel.h revision 9841d92b8d41356a72d5ca2b815906f581616c7d
1/* 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11#ifndef WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_LINUX_VIDEO_X11_CHANNEL_H_ 12#define WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_LINUX_VIDEO_X11_CHANNEL_H_ 13 14#include "video_render_defines.h" 15#include "common_video/libyuv/include/webrtc_libyuv.h" 16#include <sys/shm.h> 17 18#include <X11/Xlib.h> 19#include <X11/Xutil.h> 20#include <X11/extensions/XShm.h> 21 22namespace webrtc { 23class CriticalSectionWrapper; 24 25#define DEFAULT_RENDER_FRAME_WIDTH 352 26#define DEFAULT_RENDER_FRAME_HEIGHT 288 27 28 29class VideoX11Channel: public VideoRenderCallback 30{ 31public: 32 VideoX11Channel(WebRtc_Word32 id); 33 34 virtual ~VideoX11Channel(); 35 36 virtual WebRtc_Word32 RenderFrame(const WebRtc_UWord32 streamId, 37 I420VideoFrame& videoFrame); 38 39 WebRtc_Word32 FrameSizeChange(WebRtc_Word32 width, WebRtc_Word32 height, 40 WebRtc_Word32 numberOfStreams); 41 WebRtc_Word32 DeliverFrame(const I420VideoFrame& videoFrame); 42 WebRtc_Word32 GetFrameSize(WebRtc_Word32& width, WebRtc_Word32& height); 43 WebRtc_Word32 Init(Window window, float left, float top, float right, 44 float bottom); 45 WebRtc_Word32 ChangeWindow(Window window); 46 WebRtc_Word32 47 GetStreamProperties(WebRtc_UWord32& zOrder, float& left, 48 float& top, float& right, float& bottom) const; 49 WebRtc_Word32 ReleaseWindow(); 50 51 bool IsPrepared() 52 { 53 return _prepared; 54 } 55 56private: 57 58 WebRtc_Word32 59 CreateLocalRenderer(WebRtc_Word32 width, WebRtc_Word32 height); 60 WebRtc_Word32 RemoveRenderer(); 61 62 //FIXME a better place for this method? the GetWidthHeight no longer 63 // supported by common_video. 64 int GetWidthHeight(VideoType type, int bufferSize, int& width, 65 int& height); 66 67 CriticalSectionWrapper& _crit; 68 69 Display* _display; 70 XShmSegmentInfo _shminfo; 71 XImage* _image; 72 Window _window; 73 GC _gc; 74 WebRtc_Word32 _width; // incoming frame width 75 WebRtc_Word32 _height; // incoming frame height 76 WebRtc_Word32 _outWidth; // render frame width 77 WebRtc_Word32 _outHeight; // render frame height 78 WebRtc_Word32 _xPos; // position within window 79 WebRtc_Word32 _yPos; 80 bool _prepared; // true if ready to use 81 WebRtc_Word32 _dispCount; 82 83 unsigned char* _buffer; 84 float _top; 85 float _left; 86 float _right; 87 float _bottom; 88 89 WebRtc_Word32 _Id; 90 91}; 92 93 94} //namespace webrtc 95 96#endif // WEBRTC_MODULES_VIDEO_RENDER_MAIN_SOURCE_LINUX_VIDEO_X11_CHANNEL_H_ 97