Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2008-2010 Teluu Inc. (http://www.teluu.com) |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | #include <pjmedia/converter.h> |
| 20 | #include <pjmedia-videodev/videodev_imp.h> |
| 21 | #include <pj/assert.h> |
| 22 | #include <pj/log.h> |
| 23 | #include <pj/os.h> |
| 24 | |
| 25 | #if PJMEDIA_VIDEO_DEV_HAS_SDL |
| 26 | |
Sauw Ming | 6e6c215 | 2010-12-14 13:03:10 +0000 | [diff] [blame] | 27 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 28 | # include <Foundation/Foundation.h> |
Sauw Ming | 6e6c215 | 2010-12-14 13:03:10 +0000 | [diff] [blame] | 29 | #endif |
| 30 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 31 | #include <SDL.h> |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 32 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
| 33 | # include "SDL_opengl.h" |
| 34 | # define OPENGL_DEV_IDX 1 |
| 35 | #endif |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 36 | |
| 37 | #define THIS_FILE "sdl_dev.c" |
| 38 | #define DEFAULT_CLOCK_RATE 90000 |
| 39 | #define DEFAULT_WIDTH 640 |
| 40 | #define DEFAULT_HEIGHT 480 |
| 41 | #define DEFAULT_FPS 25 |
| 42 | |
| 43 | |
| 44 | typedef struct sdl_fmt_info |
| 45 | { |
| 46 | pjmedia_format_id fmt_id; |
| 47 | Uint32 sdl_format; |
| 48 | Uint32 Rmask; |
| 49 | Uint32 Gmask; |
| 50 | Uint32 Bmask; |
| 51 | Uint32 Amask; |
| 52 | } sdl_fmt_info; |
| 53 | |
| 54 | static sdl_fmt_info sdl_fmts[] = |
| 55 | { |
| 56 | #if PJ_IS_BIG_ENDIAN |
| 57 | {PJMEDIA_FORMAT_RGBA, 0, 0xFF000000, 0xFF0000, 0xFF00, 0xFF} , |
| 58 | {PJMEDIA_FORMAT_RGB24, 0, 0xFF0000, 0xFF00, 0xFF, 0} , |
| 59 | {PJMEDIA_FORMAT_BGRA, 0, 0xFF00, 0xFF0000, 0xFF000000, 0xFF} , |
| 60 | #else |
| 61 | {PJMEDIA_FORMAT_RGBA, 0, 0xFF, 0xFF00, 0xFF0000, 0xFF000000} , |
| 62 | {PJMEDIA_FORMAT_RGB24, 0, 0xFF, 0xFF00, 0xFF0000, 0} , |
| 63 | {PJMEDIA_FORMAT_BGRA, 0, 0xFF0000, 0xFF00, 0xFF, 0xFF000000} , |
| 64 | #endif |
| 65 | |
| 66 | {PJMEDIA_FORMAT_DIB , 0, 0xFF0000, 0xFF00, 0xFF, 0} , |
| 67 | |
| 68 | {PJMEDIA_FORMAT_YUY2, SDL_YUY2_OVERLAY, 0, 0, 0, 0} , |
| 69 | {PJMEDIA_FORMAT_UYVY, SDL_UYVY_OVERLAY, 0, 0, 0, 0} , |
| 70 | {PJMEDIA_FORMAT_YVYU, SDL_YVYU_OVERLAY, 0, 0, 0, 0} , |
| 71 | {PJMEDIA_FORMAT_I420, SDL_IYUV_OVERLAY, 0, 0, 0, 0} , |
| 72 | {PJMEDIA_FORMAT_YV12, SDL_YV12_OVERLAY, 0, 0, 0, 0} , |
| 73 | {PJMEDIA_FORMAT_I420JPEG, SDL_IYUV_OVERLAY, 0, 0, 0, 0} , |
| 74 | {PJMEDIA_FORMAT_I422JPEG, SDL_YV12_OVERLAY, 0, 0, 0, 0} , |
| 75 | }; |
| 76 | |
| 77 | /* sdl_ device info */ |
| 78 | struct sdl_dev_info |
| 79 | { |
| 80 | pjmedia_vid_dev_info info; |
| 81 | }; |
| 82 | |
| 83 | /* sdl_ factory */ |
| 84 | struct sdl_factory |
| 85 | { |
| 86 | pjmedia_vid_dev_factory base; |
| 87 | pj_pool_t *pool; |
| 88 | pj_pool_factory *pf; |
| 89 | |
| 90 | unsigned dev_count; |
| 91 | struct sdl_dev_info *dev_info; |
| 92 | }; |
| 93 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 94 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
| 95 | @interface SDLDelegate: NSObject |
| 96 | { |
| 97 | @public |
| 98 | struct sdl_stream *strm; |
| 99 | } |
| 100 | |
| 101 | - (int)sdl_thread; |
| 102 | - (int)handle_event; |
| 103 | - (pj_status_t)put_frame; |
| 104 | @end |
| 105 | #endif |
| 106 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 107 | /* Video stream. */ |
| 108 | struct sdl_stream |
| 109 | { |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 110 | pjmedia_vid_dev_stream base; /**< Base stream */ |
| 111 | pjmedia_vid_param param; /**< Settings */ |
| 112 | pj_pool_t *pool; /**< Memory pool. */ |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 113 | |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 114 | pjmedia_vid_cb vid_cb; /**< Stream callback. */ |
| 115 | void *user_data; /**< Application data. */ |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 116 | |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 117 | pj_thread_t *sdl_thread; /**< SDL thread. */ |
| 118 | pj_bool_t is_quitting; |
| 119 | pj_bool_t is_running; |
| 120 | pj_bool_t render_exited; |
| 121 | pj_status_t status; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 122 | |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 123 | SDL_Rect rect; /**< Display rectangle. */ |
| 124 | SDL_Surface *screen; /**< Display screen. */ |
| 125 | SDL_Surface *surf; /**< RGB surface. */ |
| 126 | SDL_Overlay *overlay; /**< YUV overlay. */ |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 127 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
| 128 | GLuint texture; |
Sauw Ming | 0254829 | 2011-04-11 21:38:53 +0000 | [diff] [blame] | 129 | void *tex_buf; |
| 130 | pj_size_t tex_buf_size; |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 131 | #endif |
| 132 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
| 133 | NSAutoreleasePool *apool; |
| 134 | SDLDelegate *delegate; |
| 135 | const pjmedia_frame *frame; |
| 136 | #endif |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 137 | |
| 138 | /* For frame conversion */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 139 | pjmedia_converter *conv; |
| 140 | pjmedia_conversion_param conv_param; |
| 141 | pjmedia_frame conv_buf; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 142 | |
| 143 | pjmedia_video_apply_fmt_param vafp; |
| 144 | }; |
| 145 | |
| 146 | |
| 147 | /* Prototypes */ |
| 148 | static pj_status_t sdl_factory_init(pjmedia_vid_dev_factory *f); |
| 149 | static pj_status_t sdl_factory_destroy(pjmedia_vid_dev_factory *f); |
| 150 | static unsigned sdl_factory_get_dev_count(pjmedia_vid_dev_factory *f); |
| 151 | static pj_status_t sdl_factory_get_dev_info(pjmedia_vid_dev_factory *f, |
| 152 | unsigned index, |
| 153 | pjmedia_vid_dev_info *info); |
| 154 | static pj_status_t sdl_factory_default_param(pj_pool_t *pool, |
| 155 | pjmedia_vid_dev_factory *f, |
| 156 | unsigned index, |
| 157 | pjmedia_vid_param *param); |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 158 | static pj_status_t sdl_factory_create_stream( |
| 159 | pjmedia_vid_dev_factory *f, |
Benny Prijono | e9f70d8 | 2011-03-25 08:38:26 +0000 | [diff] [blame] | 160 | pjmedia_vid_param *param, |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 161 | const pjmedia_vid_cb *cb, |
| 162 | void *user_data, |
| 163 | pjmedia_vid_dev_stream **p_vid_strm); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 164 | |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 165 | static pj_status_t sdl_stream_get_param(pjmedia_vid_dev_stream *strm, |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 166 | pjmedia_vid_param *param); |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 167 | static pj_status_t sdl_stream_get_cap(pjmedia_vid_dev_stream *strm, |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 168 | pjmedia_vid_dev_cap cap, |
| 169 | void *value); |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 170 | static pj_status_t sdl_stream_set_cap(pjmedia_vid_dev_stream *strm, |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 171 | pjmedia_vid_dev_cap cap, |
| 172 | const void *value); |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 173 | static pj_status_t sdl_stream_put_frame(pjmedia_vid_dev_stream *strm, |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 174 | const pjmedia_frame *frame); |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 175 | static pj_status_t sdl_stream_start(pjmedia_vid_dev_stream *strm); |
| 176 | static pj_status_t sdl_stream_stop(pjmedia_vid_dev_stream *strm); |
| 177 | static pj_status_t sdl_stream_destroy(pjmedia_vid_dev_stream *strm); |
Benny Prijono | da1d3f7 | 2011-04-13 14:21:10 +0000 | [diff] [blame] | 178 | |
| 179 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
Sauw Ming | 0254829 | 2011-04-11 21:38:53 +0000 | [diff] [blame] | 180 | static void draw_gl(struct sdl_stream *stream, void *tex_buf); |
Benny Prijono | da1d3f7 | 2011-04-13 14:21:10 +0000 | [diff] [blame] | 181 | #endif |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 182 | |
| 183 | /* Operations */ |
| 184 | static pjmedia_vid_dev_factory_op factory_op = |
| 185 | { |
| 186 | &sdl_factory_init, |
| 187 | &sdl_factory_destroy, |
| 188 | &sdl_factory_get_dev_count, |
| 189 | &sdl_factory_get_dev_info, |
| 190 | &sdl_factory_default_param, |
| 191 | &sdl_factory_create_stream |
| 192 | }; |
| 193 | |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 194 | static pjmedia_vid_dev_stream_op stream_op = |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 195 | { |
| 196 | &sdl_stream_get_param, |
| 197 | &sdl_stream_get_cap, |
| 198 | &sdl_stream_set_cap, |
| 199 | &sdl_stream_start, |
| 200 | NULL, |
| 201 | &sdl_stream_put_frame, |
| 202 | &sdl_stream_stop, |
| 203 | &sdl_stream_destroy |
| 204 | }; |
| 205 | |
| 206 | |
| 207 | /**************************************************************************** |
| 208 | * Factory operations |
| 209 | */ |
| 210 | /* |
| 211 | * Init sdl_ video driver. |
| 212 | */ |
| 213 | pjmedia_vid_dev_factory* pjmedia_sdl_factory(pj_pool_factory *pf) |
| 214 | { |
| 215 | struct sdl_factory *f; |
| 216 | pj_pool_t *pool; |
| 217 | |
| 218 | pool = pj_pool_create(pf, "sdl video", 1000, 1000, NULL); |
| 219 | f = PJ_POOL_ZALLOC_T(pool, struct sdl_factory); |
| 220 | f->pf = pf; |
| 221 | f->pool = pool; |
| 222 | f->base.op = &factory_op; |
| 223 | |
| 224 | return &f->base; |
| 225 | } |
| 226 | |
| 227 | |
| 228 | /* API: init factory */ |
| 229 | static pj_status_t sdl_factory_init(pjmedia_vid_dev_factory *f) |
| 230 | { |
| 231 | struct sdl_factory *sf = (struct sdl_factory*)f; |
| 232 | struct sdl_dev_info *ddi; |
| 233 | unsigned i; |
| 234 | |
| 235 | sf->dev_count = 1; |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 236 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
| 237 | sf->dev_count++; |
| 238 | #endif |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 239 | sf->dev_info = (struct sdl_dev_info*) |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 240 | pj_pool_calloc(sf->pool, sf->dev_count, |
| 241 | sizeof(struct sdl_dev_info)); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 242 | |
| 243 | ddi = &sf->dev_info[0]; |
| 244 | pj_bzero(ddi, sizeof(*ddi)); |
| 245 | strncpy(ddi->info.name, "SDL renderer", sizeof(ddi->info.name)); |
| 246 | ddi->info.name[sizeof(ddi->info.name)-1] = '\0'; |
| 247 | strncpy(ddi->info.driver, "SDL", sizeof(ddi->info.driver)); |
| 248 | ddi->info.driver[sizeof(ddi->info.driver)-1] = '\0'; |
| 249 | ddi->info.dir = PJMEDIA_DIR_RENDER; |
| 250 | ddi->info.has_callback = PJ_FALSE; |
| 251 | ddi->info.caps = PJMEDIA_VID_DEV_CAP_FORMAT | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 252 | PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 253 | |
| 254 | ddi->info.fmt_cnt = PJ_ARRAY_SIZE(sdl_fmts); |
| 255 | ddi->info.fmt = (pjmedia_format*) |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 256 | pj_pool_calloc(sf->pool, ddi->info.fmt_cnt, |
| 257 | sizeof(pjmedia_format)); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 258 | for (i = 0; i < ddi->info.fmt_cnt; i++) { |
| 259 | pjmedia_format *fmt = &ddi->info.fmt[i]; |
| 260 | pjmedia_format_init_video(fmt, sdl_fmts[i].fmt_id, |
| 261 | DEFAULT_WIDTH, DEFAULT_HEIGHT, |
| 262 | DEFAULT_FPS, 1); |
| 263 | } |
| 264 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 265 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
| 266 | ddi = &sf->dev_info[OPENGL_DEV_IDX]; |
| 267 | pj_bzero(ddi, sizeof(*ddi)); |
| 268 | strncpy(ddi->info.name, "SDL openGL renderer", sizeof(ddi->info.name)); |
| 269 | ddi->info.name[sizeof(ddi->info.name)-1] = '\0'; |
| 270 | strncpy(ddi->info.driver, "SDL", sizeof(ddi->info.driver)); |
| 271 | ddi->info.driver[sizeof(ddi->info.driver)-1] = '\0'; |
| 272 | ddi->info.dir = PJMEDIA_DIR_RENDER; |
| 273 | ddi->info.has_callback = PJ_FALSE; |
| 274 | ddi->info.caps = PJMEDIA_VID_DEV_CAP_FORMAT; |
| 275 | |
| 276 | ddi->info.fmt_cnt = PJ_ARRAY_SIZE(sdl_fmts); |
| 277 | ddi->info.fmt_cnt = 1; |
| 278 | ddi->info.fmt = (pjmedia_format*) |
| 279 | pj_pool_calloc(sf->pool, ddi->info.fmt_cnt, |
| 280 | sizeof(pjmedia_format)); |
| 281 | for (i = 0; i < ddi->info.fmt_cnt; i++) { |
| 282 | pjmedia_format *fmt = &ddi->info.fmt[i]; |
| 283 | pjmedia_format_init_video(fmt, sdl_fmts[i].fmt_id, |
| 284 | DEFAULT_WIDTH, DEFAULT_HEIGHT, |
| 285 | DEFAULT_FPS, 1); |
| 286 | } |
| 287 | #endif |
| 288 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 289 | PJ_LOG(4, (THIS_FILE, "SDL initialized")); |
| 290 | |
| 291 | return PJ_SUCCESS; |
| 292 | } |
| 293 | |
| 294 | /* API: destroy factory */ |
| 295 | static pj_status_t sdl_factory_destroy(pjmedia_vid_dev_factory *f) |
| 296 | { |
| 297 | struct sdl_factory *sf = (struct sdl_factory*)f; |
| 298 | pj_pool_t *pool = sf->pool; |
| 299 | |
| 300 | sf->pool = NULL; |
| 301 | pj_pool_release(pool); |
| 302 | |
| 303 | return PJ_SUCCESS; |
| 304 | } |
| 305 | |
| 306 | /* API: get number of devices */ |
| 307 | static unsigned sdl_factory_get_dev_count(pjmedia_vid_dev_factory *f) |
| 308 | { |
| 309 | struct sdl_factory *sf = (struct sdl_factory*)f; |
| 310 | return sf->dev_count; |
| 311 | } |
| 312 | |
| 313 | /* API: get device info */ |
| 314 | static pj_status_t sdl_factory_get_dev_info(pjmedia_vid_dev_factory *f, |
| 315 | unsigned index, |
| 316 | pjmedia_vid_dev_info *info) |
| 317 | { |
| 318 | struct sdl_factory *sf = (struct sdl_factory*)f; |
| 319 | |
| 320 | PJ_ASSERT_RETURN(index < sf->dev_count, PJMEDIA_EVID_INVDEV); |
| 321 | |
| 322 | pj_memcpy(info, &sf->dev_info[index].info, sizeof(*info)); |
| 323 | |
| 324 | return PJ_SUCCESS; |
| 325 | } |
| 326 | |
| 327 | /* API: create default device parameter */ |
| 328 | static pj_status_t sdl_factory_default_param(pj_pool_t *pool, |
| 329 | pjmedia_vid_dev_factory *f, |
| 330 | unsigned index, |
| 331 | pjmedia_vid_param *param) |
| 332 | { |
| 333 | struct sdl_factory *sf = (struct sdl_factory*)f; |
| 334 | struct sdl_dev_info *di = &sf->dev_info[index]; |
| 335 | |
| 336 | PJ_ASSERT_RETURN(index < sf->dev_count, PJMEDIA_EVID_INVDEV); |
| 337 | |
| 338 | PJ_UNUSED_ARG(pool); |
| 339 | |
| 340 | pj_bzero(param, sizeof(*param)); |
Nanang Izzuddin | 9861070 | 2011-03-01 17:40:17 +0000 | [diff] [blame] | 341 | if (di->info.dir == PJMEDIA_DIR_CAPTURE_RENDER) { |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 342 | param->dir = PJMEDIA_DIR_CAPTURE_RENDER; |
| 343 | param->cap_id = index; |
| 344 | param->rend_id = index; |
| 345 | } else if (di->info.dir & PJMEDIA_DIR_CAPTURE) { |
| 346 | param->dir = PJMEDIA_DIR_CAPTURE; |
| 347 | param->cap_id = index; |
| 348 | param->rend_id = PJMEDIA_VID_INVALID_DEV; |
| 349 | } else if (di->info.dir & PJMEDIA_DIR_RENDER) { |
| 350 | param->dir = PJMEDIA_DIR_RENDER; |
| 351 | param->rend_id = index; |
| 352 | param->cap_id = PJMEDIA_VID_INVALID_DEV; |
| 353 | } else { |
| 354 | return PJMEDIA_EVID_INVDEV; |
| 355 | } |
| 356 | |
| 357 | /* Set the device capabilities here */ |
| 358 | param->flags = PJMEDIA_VID_DEV_CAP_FORMAT; |
| 359 | param->fmt.type = PJMEDIA_TYPE_VIDEO; |
| 360 | param->clock_rate = DEFAULT_CLOCK_RATE; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 361 | pjmedia_format_init_video(¶m->fmt, sdl_fmts[0].fmt_id, |
| 362 | DEFAULT_WIDTH, DEFAULT_HEIGHT, |
| 363 | DEFAULT_FPS, 1); |
| 364 | |
| 365 | return PJ_SUCCESS; |
| 366 | } |
| 367 | |
| 368 | static sdl_fmt_info* get_sdl_format_info(pjmedia_format_id id) |
| 369 | { |
| 370 | unsigned i; |
| 371 | |
| 372 | for (i = 0; i < sizeof(sdl_fmts)/sizeof(sdl_fmts[0]); i++) { |
| 373 | if (sdl_fmts[i].fmt_id == id) |
| 374 | return &sdl_fmts[i]; |
| 375 | } |
| 376 | |
| 377 | return NULL; |
| 378 | } |
| 379 | |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 380 | static void destroy_sdl(struct sdl_stream *strm) |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 381 | { |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 382 | if (strm->surf) { |
| 383 | SDL_FreeSurface(strm->surf); |
| 384 | strm->surf = NULL; |
| 385 | } |
| 386 | if (strm->overlay) { |
| 387 | SDL_FreeYUVOverlay(strm->overlay); |
| 388 | strm->overlay = NULL; |
| 389 | } |
| 390 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
| 391 | if (strm->texture) { |
| 392 | glDeleteTextures(1, &strm->texture); |
| 393 | strm->texture = 0; |
| 394 | } |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 395 | #endif |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 396 | } |
| 397 | |
| 398 | static pj_status_t init_sdl(struct sdl_stream *strm, pjmedia_format *fmt) |
| 399 | { |
| 400 | sdl_fmt_info *sdl_info = get_sdl_format_info(fmt->id); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 401 | const pjmedia_video_format_info *vfi; |
| 402 | pjmedia_video_format_detail *vfd; |
| 403 | |
| 404 | vfi = pjmedia_get_video_format_info(pjmedia_video_format_mgr_instance(), |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 405 | fmt->id); |
| 406 | if (!vfi || !sdl_info) |
| 407 | return PJMEDIA_EVID_BADFORMAT; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 408 | |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 409 | strm->vafp.size = fmt->det.vid.size; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 410 | strm->vafp.buffer = NULL; |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 411 | if (vfi->apply_fmt(vfi, &strm->vafp) != PJ_SUCCESS) |
| 412 | return PJMEDIA_EVID_BADFORMAT; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 413 | |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 414 | vfd = pjmedia_format_get_video_format_detail(fmt, PJ_TRUE); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 415 | strm->rect.x = strm->rect.y = 0; |
| 416 | strm->rect.w = (Uint16)vfd->size.w; |
| 417 | strm->rect.h = (Uint16)vfd->size.h; |
| 418 | |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 419 | /* Initialize the display */ |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 420 | strm->screen = SDL_SetVideoMode(strm->rect.w, strm->rect.h, 0, ( |
| 421 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
| 422 | strm->param.rend_id == OPENGL_DEV_IDX? |
| 423 | SDL_OPENGL: |
| 424 | #endif |
| 425 | SDL_RESIZABLE | SDL_SWSURFACE)); |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 426 | if (strm->screen == NULL) |
| 427 | return PJMEDIA_EVID_SYSERR; |
| 428 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 429 | SDL_WM_SetCaption("pjmedia-SDL video", NULL); |
| 430 | |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 431 | destroy_sdl(strm); |
| 432 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 433 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
| 434 | if (strm->param.rend_id == OPENGL_DEV_IDX) { |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 435 | /* Init some OpenGL settings */ |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 436 | glDisable(GL_DEPTH_TEST); |
| 437 | glDisable(GL_CULL_FACE); |
| 438 | glEnable(GL_TEXTURE_2D); |
| 439 | |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 440 | /* Init the viewport */ |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 441 | glViewport(0, 0, strm->rect.w, strm->rect.h); |
| 442 | glMatrixMode(GL_PROJECTION); |
| 443 | glLoadIdentity(); |
| 444 | |
| 445 | glOrtho(0.0, (GLdouble)strm->rect.w, (GLdouble)strm->rect.h, |
| 446 | 0.0, 0.0, 1.0); |
| 447 | |
| 448 | glMatrixMode(GL_MODELVIEW); |
| 449 | glLoadIdentity(); |
| 450 | |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 451 | /* Create a texture */ |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 452 | glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); |
| 453 | glGenTextures(1, &strm->texture); |
Sauw Ming | 0254829 | 2011-04-11 21:38:53 +0000 | [diff] [blame] | 454 | |
| 455 | #if defined(PJ_WIN32) && PJ_WIN32 != 0 |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 456 | /** |
| 457 | * On Win32 platform, the OpenGL drawing must be in the same |
| 458 | * thread that calls SDL_SetVideoMode(), hence we need a buffer |
| 459 | * for the frame from sdl_stream_put_frame() |
| 460 | */ |
Sauw Ming | 0254829 | 2011-04-11 21:38:53 +0000 | [diff] [blame] | 461 | if (strm->vafp.framebytes > strm->tex_buf_size) { |
| 462 | strm->tex_buf_size = strm->vafp.framebytes; |
| 463 | strm->tex_buf = pj_pool_alloc(strm->pool, strm->vafp.framebytes); |
| 464 | } |
| 465 | #endif |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 466 | } else |
| 467 | #endif |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 468 | if (vfi->color_model == PJMEDIA_COLOR_MODEL_RGB) { |
| 469 | strm->surf = SDL_CreateRGBSurface(SDL_SWSURFACE, |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 470 | strm->rect.w, strm->rect.h, |
| 471 | vfi->bpp, |
| 472 | sdl_info->Rmask, |
| 473 | sdl_info->Gmask, |
| 474 | sdl_info->Bmask, |
| 475 | sdl_info->Amask); |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 476 | if (strm->surf == NULL) |
| 477 | return PJMEDIA_EVID_SYSERR; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 478 | } else if (vfi->color_model == PJMEDIA_COLOR_MODEL_YUV) { |
| 479 | strm->overlay = SDL_CreateYUVOverlay(strm->rect.w, strm->rect.h, |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 480 | sdl_info->sdl_format, |
| 481 | strm->screen); |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 482 | if (strm->overlay == NULL) |
| 483 | return PJMEDIA_EVID_SYSERR; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 484 | } |
| 485 | |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 486 | return PJ_SUCCESS; |
| 487 | } |
| 488 | |
| 489 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
| 490 | @implementation SDLDelegate |
| 491 | - (int)sdl_thread |
| 492 | { |
| 493 | #else |
| 494 | static int sdlthread(void * data) |
| 495 | { |
| 496 | struct sdl_stream *strm = (struct sdl_stream*)data; |
| 497 | #endif |
| 498 | |
| 499 | /* Initialize the SDL library */ |
| 500 | if (SDL_Init(SDL_INIT_VIDEO)) { |
| 501 | PJ_LOG(4, (THIS_FILE, "Cannot initialize SDL")); |
| 502 | strm->status = PJMEDIA_EVID_INIT; |
| 503 | goto on_return; |
| 504 | } |
| 505 | |
| 506 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
| 507 | if (strm->param.rend_id == OPENGL_DEV_IDX) { |
| 508 | SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); |
| 509 | } |
| 510 | #endif |
| 511 | |
| 512 | strm->status = init_sdl(strm, &strm->param.fmt); |
| 513 | if (strm->status != PJ_SUCCESS) |
| 514 | goto on_return; |
| 515 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 516 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
| 517 | on_return: |
| 518 | if (strm->status != PJ_SUCCESS) { |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 519 | destory_sdl(strm); |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 520 | SDL_Quit(); |
| 521 | strm->screen = NULL; |
| 522 | } |
| 523 | |
| 524 | return strm->status; |
| 525 | } |
| 526 | |
| 527 | - (int)handle_event |
| 528 | { |
| 529 | sdl_fmt_info *sdl_info = get_sdl_format_info(strm->param.fmt.id); |
| 530 | const pjmedia_video_format_info *vfi; |
| 531 | pjmedia_video_format_detail *vfd; |
| 532 | |
| 533 | vfi = pjmedia_get_video_format_info(pjmedia_video_format_mgr_instance(), |
| 534 | strm->param.fmt.id); |
| 535 | vfd = pjmedia_format_get_video_format_detail(&strm->param.fmt, PJ_TRUE); |
| 536 | #else |
| 537 | while(!strm->is_quitting) |
| 538 | #endif |
| 539 | { |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 540 | SDL_Event sevent; |
| 541 | pjmedia_vid_event pevent; |
| 542 | |
Sauw Ming | 0254829 | 2011-04-11 21:38:53 +0000 | [diff] [blame] | 543 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
| 544 | #if defined(PJ_WIN32) && PJ_WIN32 != 0 |
| 545 | if (strm->param.rend_id == OPENGL_DEV_IDX) { |
| 546 | draw_gl(strm, strm->tex_buf); |
| 547 | } |
| 548 | #endif |
| 549 | #endif |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 550 | /** |
| 551 | * The event polling must be placed in the same thread that |
| 552 | * call SDL_SetVideoMode(). Please consult the official doc of |
| 553 | * SDL_PumpEvents(). |
| 554 | */ |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 555 | while (SDL_PollEvent(&sevent)) { |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 556 | pj_bzero(&pevent, sizeof(pevent)); |
| 557 | |
| 558 | switch(sevent.type) { |
| 559 | case SDL_USEREVENT: |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 560 | { |
| 561 | pjmedia_format *fmt; |
| 562 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 563 | if (sevent.user.code == PJMEDIA_EVENT_NONE) { |
| 564 | strm->is_quitting = PJ_TRUE; |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 565 | goto on_return; |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 566 | } |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 567 | |
| 568 | pj_assert(sevent.user.code == PJMEDIA_VID_DEV_CAP_FORMAT); |
| 569 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 570 | fmt = (pjmedia_format *)sevent.user.data1; |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 571 | |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 572 | /* Stop the stream */ |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 573 | sdl_stream_stop((pjmedia_vid_dev_stream *)strm); |
| 574 | |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 575 | /* Re-initialize SDL */ |
| 576 | strm->status = init_sdl(strm, fmt); |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 577 | |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 578 | if (strm->status == PJ_SUCCESS) { |
| 579 | pjmedia_format_copy(&strm->param.fmt, fmt); |
| 580 | /* Restart the stream */ |
| 581 | sdl_stream_start((pjmedia_vid_dev_stream *)strm); |
| 582 | } |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 583 | |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 584 | break; |
| 585 | } |
| 586 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 587 | case SDL_MOUSEBUTTONDOWN: |
| 588 | pevent.event_type = PJMEDIA_EVENT_MOUSEBUTTONDOWN; |
| 589 | if (strm->vid_cb.on_event_cb) |
| 590 | if ((*strm->vid_cb.on_event_cb)(&strm->base, |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 591 | strm->user_data, |
| 592 | &pevent) != PJ_SUCCESS) |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 593 | { |
| 594 | /* Application wants us to ignore this event */ |
| 595 | break; |
| 596 | } |
| 597 | if (strm->is_running) |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 598 | pjmedia_vid_dev_stream_stop(&strm->base); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 599 | else |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 600 | pjmedia_vid_dev_stream_start(&strm->base); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 601 | break; |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 602 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 603 | case SDL_VIDEORESIZE: |
| 604 | pevent.event_type = PJMEDIA_EVENT_WINDOW_RESIZE; |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 605 | pevent.event_desc.resize.new_size.w = sevent.resize.w; |
| 606 | pevent.event_desc.resize.new_size.h = sevent.resize.h; |
| 607 | if (strm->vid_cb.on_event_cb) { |
| 608 | /** |
| 609 | * To process PJMEDIA_EVENT_WINDOW_RESIZE event, |
| 610 | * application should do this in the on_event_cb |
| 611 | * callback: |
| 612 | * 1. change the input frame size given to SDL |
| 613 | * to the new size. |
| 614 | * 2. call pjmedia_vid_dev_stream_set_cap() |
| 615 | * using PJMEDIA_VID_DEV_CAP_FORMAT capability |
| 616 | * and the new format size |
| 617 | */ |
| 618 | (*strm->vid_cb.on_event_cb)(&strm->base, |
| 619 | strm->user_data, |
| 620 | &pevent); |
| 621 | } |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 622 | break; |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 623 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 624 | case SDL_QUIT: |
| 625 | pevent.event_type = PJMEDIA_EVENT_WINDOW_CLOSE; |
| 626 | /** |
| 627 | * To process PJMEDIA_EVENT_WINDOW_CLOSE event, |
| 628 | * application should do this in the on_event_cb callback: |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 629 | * 1. stop further calls to |
| 630 | * #pjmedia_vid_dev_stream_put_frame() |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 631 | * 2. return PJ_SUCCESS |
| 632 | * Upon returning from the callback, SDL will destroy its |
| 633 | * own stream. |
| 634 | * |
| 635 | * Returning non-PJ_SUCCESS will cause SDL to ignore |
| 636 | * the event |
| 637 | */ |
| 638 | if (strm->vid_cb.on_event_cb) { |
| 639 | strm->is_quitting = PJ_TRUE; |
| 640 | if ((*strm->vid_cb.on_event_cb)(&strm->base, |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 641 | strm->user_data, |
| 642 | &pevent) != PJ_SUCCESS) |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 643 | { |
| 644 | /* Application wants us to ignore this event */ |
| 645 | strm->is_quitting = PJ_FALSE; |
| 646 | break; |
| 647 | } |
| 648 | |
| 649 | /* Destroy the stream */ |
| 650 | sdl_stream_destroy(&strm->base); |
Sauw Ming | 6e6c215 | 2010-12-14 13:03:10 +0000 | [diff] [blame] | 651 | goto on_return; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | /** |
| 655 | * Default event-handler when there is no user-specified |
| 656 | * callback: close the renderer window. We cannot destroy |
| 657 | * the stream here since there is no callback to notify |
| 658 | * the application. |
| 659 | */ |
| 660 | sdl_stream_stop(&strm->base); |
Sauw Ming | 6e6c215 | 2010-12-14 13:03:10 +0000 | [diff] [blame] | 661 | goto on_return; |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 662 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 663 | default: |
| 664 | break; |
| 665 | } |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 666 | } |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 667 | } |
| 668 | |
Sauw Ming | 6e6c215 | 2010-12-14 13:03:10 +0000 | [diff] [blame] | 669 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 670 | return 0; |
Sauw Ming | 6e6c215 | 2010-12-14 13:03:10 +0000 | [diff] [blame] | 671 | #endif |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 672 | on_return: |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 673 | destroy_sdl(strm); |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 674 | SDL_Quit(); |
| 675 | strm->screen = NULL; |
| 676 | |
Sauw Ming | 6e6c215 | 2010-12-14 13:03:10 +0000 | [diff] [blame] | 677 | return strm->status; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 678 | } |
| 679 | |
Benny Prijono | da1d3f7 | 2011-04-13 14:21:10 +0000 | [diff] [blame] | 680 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
Sauw Ming | 0254829 | 2011-04-11 21:38:53 +0000 | [diff] [blame] | 681 | static void draw_gl(struct sdl_stream *stream, void *tex_buf) |
| 682 | { |
| 683 | if (stream->texture) { |
| 684 | glBindTexture(GL_TEXTURE_2D, stream->texture); |
| 685 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 686 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 687 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, |
| 688 | stream->rect.w, stream->rect.h, 0, |
| 689 | GL_RGBA, GL_UNSIGNED_BYTE, tex_buf); |
| 690 | glBegin(GL_TRIANGLE_STRIP); |
| 691 | glTexCoord2f(0, 0); glVertex2i(0, 0); |
| 692 | glTexCoord2f(1, 0); glVertex2i(stream->rect.w, 0); |
| 693 | glTexCoord2f(0, 1); glVertex2i(0, stream->rect.h); |
| 694 | glTexCoord2f(1, 1); glVertex2i(stream->rect.w, stream->rect.h); |
| 695 | glEnd(); |
| 696 | SDL_GL_SwapBuffers(); |
| 697 | } |
| 698 | } |
Benny Prijono | da1d3f7 | 2011-04-13 14:21:10 +0000 | [diff] [blame] | 699 | #endif |
Sauw Ming | 0254829 | 2011-04-11 21:38:53 +0000 | [diff] [blame] | 700 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 701 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
| 702 | - (pj_status_t)put_frame |
| 703 | { |
| 704 | const pjmedia_frame *frame = strm->frame; |
| 705 | #else |
| 706 | /* API: Put frame from stream */ |
| 707 | static pj_status_t sdl_stream_put_frame(pjmedia_vid_dev_stream *strm, |
| 708 | const pjmedia_frame *frame) |
| 709 | { |
| 710 | #endif |
| 711 | struct sdl_stream *stream = (struct sdl_stream*)strm; |
| 712 | pj_status_t status = PJ_SUCCESS; |
| 713 | |
| 714 | if (!stream->is_running) { |
| 715 | stream->render_exited = PJ_TRUE; |
| 716 | goto on_return; |
| 717 | } |
| 718 | |
Sauw Ming | f7b429c | 2011-04-08 04:04:25 +0000 | [diff] [blame] | 719 | if (frame->size==0 || frame->buf==NULL || |
| 720 | frame->size < stream->vafp.framebytes) |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 721 | goto on_return; |
| 722 | |
| 723 | if (stream->surf) { |
| 724 | if (SDL_MUSTLOCK(stream->surf)) { |
| 725 | if (SDL_LockSurface(stream->surf) < 0) { |
| 726 | PJ_LOG(3, (THIS_FILE, "Unable to lock SDL surface")); |
| 727 | status = PJMEDIA_EVID_NOTREADY; |
| 728 | goto on_return; |
| 729 | } |
| 730 | } |
| 731 | |
Sauw Ming | f7b429c | 2011-04-08 04:04:25 +0000 | [diff] [blame] | 732 | pj_memcpy(stream->surf->pixels, frame->buf, |
| 733 | stream->vafp.framebytes); |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 734 | |
| 735 | if (SDL_MUSTLOCK(stream->surf)) { |
| 736 | SDL_UnlockSurface(stream->surf); |
| 737 | } |
| 738 | SDL_BlitSurface(stream->surf, NULL, stream->screen, NULL); |
| 739 | SDL_UpdateRect(stream->screen, 0, 0, 0, 0); |
| 740 | } else if (stream->overlay) { |
| 741 | int i, sz, offset; |
| 742 | |
| 743 | if (SDL_LockYUVOverlay(stream->overlay) < 0) { |
| 744 | PJ_LOG(3, (THIS_FILE, "Unable to lock SDL overlay")); |
| 745 | status = PJMEDIA_EVID_NOTREADY; |
| 746 | goto on_return; |
| 747 | } |
| 748 | |
| 749 | for (i = 0, offset = 0; i < stream->overlay->planes; i++) { |
| 750 | sz = stream->vafp.plane_bytes[i]; |
| 751 | pj_memcpy(stream->overlay->pixels[i], |
| 752 | (char *)frame->buf + offset, sz); |
| 753 | offset += sz; |
| 754 | } |
| 755 | |
| 756 | SDL_UnlockYUVOverlay(stream->overlay); |
| 757 | SDL_DisplayYUVOverlay(stream->overlay, &stream->rect); |
| 758 | } |
| 759 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
Sauw Ming | 0254829 | 2011-04-11 21:38:53 +0000 | [diff] [blame] | 760 | else if (stream->param.rend_id == OPENGL_DEV_IDX) { |
| 761 | #if defined(PJ_WIN32) && PJ_WIN32 != 0 |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 762 | pj_memcpy(stream->tex_buf, frame->buf, stream->vafp.framebytes); |
Sauw Ming | 0254829 | 2011-04-11 21:38:53 +0000 | [diff] [blame] | 763 | #else |
| 764 | draw_gl(stream, frame->buf); |
| 765 | #endif |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 766 | } |
| 767 | #endif |
| 768 | |
| 769 | on_return: |
| 770 | return status; |
| 771 | } |
| 772 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
| 773 | @end |
| 774 | |
| 775 | static pj_status_t sdl_stream_put_frame(pjmedia_vid_dev_stream *strm, |
| 776 | const pjmedia_frame *frame) |
| 777 | { |
| 778 | struct sdl_stream *stream = (struct sdl_stream*)strm; |
| 779 | stream->frame = frame; |
| 780 | [stream->delegate performSelectorOnMainThread:@selector(put_frame) |
| 781 | withObject:nil waitUntilDone:YES]; |
| 782 | |
| 783 | return PJ_SUCCESS; |
| 784 | } |
| 785 | |
| 786 | static int sdlthread(void * data) |
| 787 | { |
| 788 | struct sdl_stream *strm = (struct sdl_stream*)data; |
| 789 | |
| 790 | while(!strm->is_quitting) { |
| 791 | [strm->delegate performSelectorOnMainThread:@selector(handle_event) |
| 792 | withObject:nil waitUntilDone:YES]; |
| 793 | } |
| 794 | |
| 795 | return 0; |
| 796 | } |
| 797 | |
| 798 | #endif |
| 799 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 800 | /* API: create stream */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 801 | static pj_status_t sdl_factory_create_stream( |
| 802 | pjmedia_vid_dev_factory *f, |
Benny Prijono | e9f70d8 | 2011-03-25 08:38:26 +0000 | [diff] [blame] | 803 | pjmedia_vid_param *param, |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 804 | const pjmedia_vid_cb *cb, |
| 805 | void *user_data, |
| 806 | pjmedia_vid_dev_stream **p_vid_strm) |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 807 | { |
| 808 | struct sdl_factory *sf = (struct sdl_factory*)f; |
| 809 | pj_pool_t *pool; |
| 810 | struct sdl_stream *strm; |
| 811 | pj_status_t status; |
| 812 | |
| 813 | /* Create and Initialize stream descriptor */ |
| 814 | pool = pj_pool_create(sf->pf, "sdl-dev", 1000, 1000, NULL); |
| 815 | PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM); |
| 816 | |
| 817 | strm = PJ_POOL_ZALLOC_T(pool, struct sdl_stream); |
| 818 | pj_memcpy(&strm->param, param, sizeof(*param)); |
| 819 | strm->pool = pool; |
| 820 | pj_memcpy(&strm->vid_cb, cb, sizeof(*cb)); |
| 821 | strm->user_data = user_data; |
| 822 | |
| 823 | /* Create capture stream here */ |
| 824 | if (param->dir & PJMEDIA_DIR_CAPTURE) { |
| 825 | } |
| 826 | |
| 827 | /* Create render stream here */ |
| 828 | if (param->dir & PJMEDIA_DIR_RENDER) { |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 829 | strm->status = PJ_SUCCESS; |
| 830 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
| 831 | pj_assert(![NSThread isMainThread]); |
| 832 | strm->apool = [[NSAutoreleasePool alloc] init]; |
| 833 | strm->delegate = [[SDLDelegate alloc]init]; |
| 834 | strm->delegate->strm = strm; |
Sauw Ming | 093c569 | 2011-04-13 20:06:12 +0000 | [diff] [blame^] | 835 | /* On Mac OS X, we need to call SDL functions in the main thread */ |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 836 | [strm->delegate performSelectorOnMainThread:@selector(sdl_thread) |
| 837 | withObject:nil waitUntilDone:YES]; |
| 838 | if ((status = strm->status) != PJ_SUCCESS) { |
| 839 | goto on_error; |
| 840 | } |
| 841 | #endif |
| 842 | status = pj_thread_create(pool, "sdl_thread", sdlthread, |
| 843 | strm, 0, 0, &strm->sdl_thread); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 844 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 845 | if (status != PJ_SUCCESS) { |
| 846 | goto on_error; |
| 847 | } |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 848 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 849 | while(strm->status == PJ_SUCCESS && !strm->surf && !strm->overlay |
| 850 | #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
| 851 | && !strm->texture |
| 852 | #endif |
| 853 | ) |
| 854 | { |
| 855 | pj_thread_sleep(10); |
| 856 | } |
| 857 | if ((status = strm->status) != PJ_SUCCESS) { |
| 858 | goto on_error; |
| 859 | } |
| 860 | |
| 861 | pjmedia_format_copy(&strm->conv_param.src, ¶m->fmt); |
| 862 | pjmedia_format_copy(&strm->conv_param.dst, ¶m->fmt); |
| 863 | /* |
| 864 | status = pjmedia_converter_create(NULL, pool, &strm->conv_param, |
| 865 | &strm->conv); |
| 866 | */ |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 867 | } |
| 868 | |
| 869 | /* Apply the remaining settings */ |
| 870 | if (param->flags & PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW) { |
| 871 | sdl_stream_set_cap(&strm->base, |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 872 | PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW, |
| 873 | ¶m->window); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 874 | } |
| 875 | |
| 876 | /* Done */ |
| 877 | strm->base.op = &stream_op; |
| 878 | *p_vid_strm = &strm->base; |
| 879 | |
| 880 | return PJ_SUCCESS; |
| 881 | |
| 882 | on_error: |
| 883 | sdl_stream_destroy(&strm->base); |
| 884 | return status; |
| 885 | } |
| 886 | |
| 887 | /* API: Get stream info. */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 888 | static pj_status_t sdl_stream_get_param(pjmedia_vid_dev_stream *s, |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 889 | pjmedia_vid_param *pi) |
| 890 | { |
| 891 | struct sdl_stream *strm = (struct sdl_stream*)s; |
| 892 | |
| 893 | PJ_ASSERT_RETURN(strm && pi, PJ_EINVAL); |
| 894 | |
| 895 | pj_memcpy(pi, &strm->param, sizeof(*pi)); |
| 896 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 897 | /* |
| 898 | if (sdl_stream_get_cap(s, PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW, |
| 899 | &pi->fmt.info_size) == PJ_SUCCESS) |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 900 | { |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 901 | pi->flags |= PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 902 | } |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 903 | */ |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 904 | return PJ_SUCCESS; |
| 905 | } |
| 906 | |
| 907 | /* API: get capability */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 908 | static pj_status_t sdl_stream_get_cap(pjmedia_vid_dev_stream *s, |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 909 | pjmedia_vid_dev_cap cap, |
| 910 | void *pval) |
| 911 | { |
| 912 | struct sdl_stream *strm = (struct sdl_stream*)s; |
| 913 | |
| 914 | PJ_UNUSED_ARG(strm); |
| 915 | |
| 916 | PJ_ASSERT_RETURN(s && pval, PJ_EINVAL); |
| 917 | |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 918 | if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW) |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 919 | { |
| 920 | return PJ_SUCCESS; |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 921 | } else if (cap == PJMEDIA_VID_DEV_CAP_FORMAT) { |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 922 | return PJ_SUCCESS; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 923 | } else { |
| 924 | return PJMEDIA_EVID_INVCAP; |
| 925 | } |
| 926 | } |
| 927 | |
| 928 | /* API: set capability */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 929 | static pj_status_t sdl_stream_set_cap(pjmedia_vid_dev_stream *s, |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 930 | pjmedia_vid_dev_cap cap, |
| 931 | const void *pval) |
| 932 | { |
| 933 | struct sdl_stream *strm = (struct sdl_stream*)s; |
| 934 | |
| 935 | PJ_UNUSED_ARG(strm); |
| 936 | |
| 937 | PJ_ASSERT_RETURN(s && pval, PJ_EINVAL); |
| 938 | |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 939 | if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW) { |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 940 | return PJ_SUCCESS; |
Sauw Ming | 4a20bc8 | 2011-03-01 15:55:34 +0000 | [diff] [blame] | 941 | } else if (cap == PJMEDIA_VID_DEV_CAP_FORMAT) { |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 942 | SDL_Event sevent; |
| 943 | |
| 944 | strm->status = PJ_TRUE; |
| 945 | sevent.type = SDL_USEREVENT; |
| 946 | sevent.user.code = PJMEDIA_VID_DEV_CAP_FORMAT; |
| 947 | sevent.user.data1 = (void *)pval; |
| 948 | SDL_PushEvent(&sevent); |
| 949 | |
| 950 | while (strm->status == PJ_TRUE) |
| 951 | pj_thread_sleep(10); |
| 952 | |
| 953 | if (strm->status != PJ_SUCCESS) { |
| 954 | pj_status_t status = strm->status; |
| 955 | |
| 956 | /** |
| 957 | * Failed to change the output format. Try to revert |
| 958 | * to its original format. |
| 959 | */ |
| 960 | strm->status = PJ_TRUE; |
| 961 | sevent.user.data1 = &strm->param.fmt; |
| 962 | SDL_PushEvent(&sevent); |
| 963 | |
| 964 | while (strm->status == PJ_TRUE) |
| 965 | pj_thread_sleep(10); |
| 966 | |
| 967 | if (strm->status != PJ_SUCCESS) { |
| 968 | /** |
| 969 | * This means that we failed to revert to our |
| 970 | * original state! |
| 971 | */ |
| 972 | status = PJMEDIA_EVID_ERR; |
| 973 | } |
| 974 | |
| 975 | strm->status = status; |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 976 | } |
| 977 | |
| 978 | return strm->status; |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 979 | } |
| 980 | |
| 981 | return PJMEDIA_EVID_INVCAP; |
| 982 | } |
| 983 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 984 | /* API: Start stream. */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 985 | static pj_status_t sdl_stream_start(pjmedia_vid_dev_stream *strm) |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 986 | { |
| 987 | struct sdl_stream *stream = (struct sdl_stream*)strm; |
| 988 | |
| 989 | PJ_LOG(4, (THIS_FILE, "Starting sdl video stream")); |
| 990 | |
| 991 | stream->is_running = PJ_TRUE; |
| 992 | stream->render_exited = PJ_FALSE; |
| 993 | |
| 994 | return PJ_SUCCESS; |
| 995 | } |
| 996 | |
| 997 | /* API: Stop stream. */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 998 | static pj_status_t sdl_stream_stop(pjmedia_vid_dev_stream *strm) |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 999 | { |
| 1000 | struct sdl_stream *stream = (struct sdl_stream*)strm; |
| 1001 | unsigned i; |
| 1002 | |
| 1003 | PJ_LOG(4, (THIS_FILE, "Stopping sdl video stream")); |
| 1004 | |
| 1005 | /* Wait for renderer put_frame() to finish */ |
| 1006 | stream->is_running = PJ_FALSE; |
| 1007 | for (i=0; !stream->render_exited && i<100; ++i) |
| 1008 | pj_thread_sleep(10); |
| 1009 | |
| 1010 | return PJ_SUCCESS; |
| 1011 | } |
| 1012 | |
| 1013 | |
| 1014 | /* API: Destroy stream. */ |
Nanang Izzuddin | a9c1cf4 | 2011-02-24 07:47:55 +0000 | [diff] [blame] | 1015 | static pj_status_t sdl_stream_destroy(pjmedia_vid_dev_stream *strm) |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 1016 | { |
| 1017 | struct sdl_stream *stream = (struct sdl_stream*)strm; |
| 1018 | SDL_Event sevent; |
| 1019 | |
| 1020 | PJ_ASSERT_RETURN(stream != NULL, PJ_EINVAL); |
| 1021 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 1022 | sdl_stream_stop(strm); |
| 1023 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 1024 | if (!stream->is_quitting) { |
| 1025 | sevent.type = SDL_USEREVENT; |
| 1026 | sevent.user.code = PJMEDIA_EVENT_NONE; |
| 1027 | SDL_PushEvent(&sevent); |
| 1028 | if (stream->sdl_thread) |
| 1029 | pj_thread_join(stream->sdl_thread); |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 1030 | } |
| 1031 | |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 1032 | #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 |
| 1033 | if (stream->delegate) |
| 1034 | [stream->delegate release]; |
| 1035 | if (stream->apool) |
| 1036 | [stream->apool release]; |
| 1037 | #endif |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 1038 | pj_pool_release(stream->pool); |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 1039 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 1040 | |
| 1041 | return PJ_SUCCESS; |
| 1042 | } |
| 1043 | |
Nanang Izzuddin | e43ee72 | 2010-12-10 20:55:13 +0000 | [diff] [blame] | 1044 | #ifdef _MSC_VER |
| 1045 | # pragma comment( lib, "sdl.lib") |
Sauw Ming | 21bd3fd | 2011-04-06 11:30:18 +0000 | [diff] [blame] | 1046 | # if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL |
| 1047 | # pragma comment(lib, "OpenGL32.lib") |
| 1048 | # endif |
Nanang Izzuddin | e43ee72 | 2010-12-10 20:55:13 +0000 | [diff] [blame] | 1049 | #endif |
| 1050 | |
Benny Prijono | c45d951 | 2010-12-10 11:04:30 +0000 | [diff] [blame] | 1051 | #endif /* PJMEDIA_VIDEO_DEV_HAS_SDL */ |