- Timestamp:
- Feb 24, 2011 7:47:55 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/ffmpeg_dev.c
r3392 r3420 68 68 typedef struct ffmpeg_stream 69 69 { 70 pjmedia_vid_ streambase;70 pjmedia_vid_dev_stream base; 71 71 ffmpeg_factory *factory; 72 72 pj_pool_t *pool; … … 81 81 static unsigned ffmpeg_factory_get_dev_count(pjmedia_vid_dev_factory *f); 82 82 static pj_status_t ffmpeg_factory_get_dev_info(pjmedia_vid_dev_factory *f, 83 unsigned index,84 pjmedia_vid_dev_info *info);83 unsigned index, 84 pjmedia_vid_dev_info *info); 85 85 static pj_status_t ffmpeg_factory_default_param(pj_pool_t *pool, 86 86 pjmedia_vid_dev_factory *f, 87 87 unsigned index, 88 88 pjmedia_vid_param *param); 89 static pj_status_t ffmpeg_factory_create_stream(pjmedia_vid_dev_factory *f, 90 const pjmedia_vid_param *param, 91 const pjmedia_vid_cb *cb, 92 void *user_data, 93 pjmedia_vid_stream **p_vid_strm); 94 95 static pj_status_t ffmpeg_stream_get_param(pjmedia_vid_stream *strm, 96 pjmedia_vid_param *param); 97 static pj_status_t ffmpeg_stream_get_cap(pjmedia_vid_stream *strm, 98 pjmedia_vid_dev_cap cap, 99 void *value); 100 static pj_status_t ffmpeg_stream_set_cap(pjmedia_vid_stream *strm, 101 pjmedia_vid_dev_cap cap, 102 const void *value); 103 static pj_status_t ffmpeg_stream_start(pjmedia_vid_stream *strm); 104 static pj_status_t ffmpeg_stream_get_frame(pjmedia_vid_stream *s, 89 static pj_status_t ffmpeg_factory_create_stream( 90 pjmedia_vid_dev_factory *f, 91 const pjmedia_vid_param *param, 92 const pjmedia_vid_cb *cb, 93 void *user_data, 94 pjmedia_vid_dev_stream **p_vid_strm); 95 96 static pj_status_t ffmpeg_stream_get_param(pjmedia_vid_dev_stream *strm, 97 pjmedia_vid_param *param); 98 static pj_status_t ffmpeg_stream_get_cap(pjmedia_vid_dev_stream *strm, 99 pjmedia_vid_dev_cap cap, 100 void *value); 101 static pj_status_t ffmpeg_stream_set_cap(pjmedia_vid_dev_stream *strm, 102 pjmedia_vid_dev_cap cap, 103 const void *value); 104 static pj_status_t ffmpeg_stream_start(pjmedia_vid_dev_stream *strm); 105 static pj_status_t ffmpeg_stream_get_frame(pjmedia_vid_dev_stream *s, 105 106 pjmedia_frame *frame); 106 static pj_status_t ffmpeg_stream_stop(pjmedia_vid_ stream *strm);107 static pj_status_t ffmpeg_stream_destroy(pjmedia_vid_ stream *strm);107 static pj_status_t ffmpeg_stream_stop(pjmedia_vid_dev_stream *strm); 108 static pj_status_t ffmpeg_stream_destroy(pjmedia_vid_dev_stream *strm); 108 109 109 110 /* Operations */ … … 118 119 }; 119 120 120 static pjmedia_vid_ stream_op stream_op =121 static pjmedia_vid_dev_stream_op stream_op = 121 122 { 122 123 &ffmpeg_stream_get_param, … … 153 154 { 154 155 AVFormatParameters fp; 155 pjmedia_video_format_detail * fmt_detail;156 pjmedia_video_format_detail *vfd; 156 157 int err; 157 158 … … 160 161 PJ_EINVAL); 161 162 162 fmt_detail = (pjmedia_video_format_detail*)param->fmt.detail;163 vfd = pjmedia_format_get_video_format_detail(¶m->fmt, PJ_TRUE); 163 164 164 165 /* Init ffmpeg format context */ … … 168 169 pj_bzero(&fp, sizeof(fp)); 169 170 fp.prealloced_context = 1; 170 fp.width = fmt_detail->size.w;171 fp.height = fmt_detail->size.h;171 fp.width = vfd->size.w; 172 fp.height = vfd->size.h; 172 173 fp.pix_fmt = PIX_FMT_BGR24; 173 fp.time_base.num = param->frame_rate.denum;174 fp.time_base.den = param->frame_rate.num;174 fp.time_base.num = vfd->fps.denum; 175 fp.time_base.den = vfd->fps.num; 175 176 176 177 /* Open capture stream */ … … 289 290 /* API: get device info */ 290 291 static pj_status_t ffmpeg_factory_get_dev_info(pjmedia_vid_dev_factory *f, 291 unsigned index,292 pjmedia_vid_dev_info *info)292 unsigned index, 293 pjmedia_vid_dev_info *info) 293 294 { 294 295 ffmpeg_factory *ff = (ffmpeg_factory*)f; … … 309 310 ffmpeg_factory *ff = (ffmpeg_factory*)f; 310 311 ffmpeg_dev_info *info; 311 pjmedia_video_format_detail *fmt_detail;312 312 313 313 PJ_ASSERT_RETURN(index < ff->dev_count, PJMEDIA_EVID_INVDEV); 314 315 PJ_UNUSED_ARG(pool); 316 314 317 info = &ff->dev_info[index]; 315 318 … … 322 325 /* Set the device capabilities here */ 323 326 param->flags = PJMEDIA_VID_DEV_CAP_FORMAT; 324 pj_memcpy(¶m->fmt, &info->base.fmt[0], sizeof(param->fmt));325 327 param->clock_rate = 90000; 326 pjmedia_format_init_video(pool, ¶m->fmt, 320, 240, 25, 1, 327 0, 0); 328 fmt_detail = (pjmedia_video_format_detail*)param->fmt.detail; 329 param->frame_rate.num = fmt_detail->fps.num; 330 param->frame_rate.denum = fmt_detail->fps.denum; 328 pjmedia_format_init_video(¶m->fmt, 0, 320, 240, 25, 1); 329 param->fmt.id = info->base.fmt[0].id; 331 330 332 331 return PJ_SUCCESS; … … 336 335 337 336 /* API: create stream */ 338 static pj_status_t ffmpeg_factory_create_stream(pjmedia_vid_dev_factory *f, 339 const pjmedia_vid_param *param, 340 const pjmedia_vid_cb *cb, 341 void *user_data, 342 pjmedia_vid_stream **p_vid_strm) 337 static pj_status_t ffmpeg_factory_create_stream( 338 pjmedia_vid_dev_factory *f, 339 const pjmedia_vid_param *param, 340 const pjmedia_vid_cb *cb, 341 void *user_data, 342 pjmedia_vid_dev_stream **p_vid_strm) 343 343 { 344 344 ffmpeg_factory *ff = (ffmpeg_factory*)f; … … 349 349 PJ_ASSERT_RETURN(param->dir == PJMEDIA_DIR_CAPTURE, PJ_EINVAL); 350 350 PJ_ASSERT_RETURN((unsigned)param->cap_id < ff->dev_count, PJ_EINVAL); 351 PJ_ASSERT_RETURN(param->fmt.detail_type == PJMEDIA_FORMAT_DETAIL_VIDEO &&352 param->fmt.detail,PJ_EINVAL);351 PJ_ASSERT_RETURN(param->fmt.detail_type == PJMEDIA_FORMAT_DETAIL_VIDEO, 352 PJ_EINVAL); 353 353 354 354 PJ_UNUSED_ARG(cb); … … 372 372 373 373 /* API: Get stream info. */ 374 static pj_status_t ffmpeg_stream_get_param(pjmedia_vid_ stream *s,374 static pj_status_t ffmpeg_stream_get_param(pjmedia_vid_dev_stream *s, 375 375 pjmedia_vid_param *pi) 376 376 { … … 385 385 386 386 /* API: get capability */ 387 static pj_status_t ffmpeg_stream_get_cap(pjmedia_vid_ stream *s,388 pjmedia_vid_dev_cap cap,389 void *pval)387 static pj_status_t ffmpeg_stream_get_cap(pjmedia_vid_dev_stream *s, 388 pjmedia_vid_dev_cap cap, 389 void *pval) 390 390 { 391 391 ffmpeg_stream *strm = (ffmpeg_stream*)s; … … 399 399 400 400 /* API: set capability */ 401 static pj_status_t ffmpeg_stream_set_cap(pjmedia_vid_ stream *s,402 pjmedia_vid_dev_cap cap,403 const void *pval)401 static pj_status_t ffmpeg_stream_set_cap(pjmedia_vid_dev_stream *s, 402 pjmedia_vid_dev_cap cap, 403 const void *pval) 404 404 { 405 405 ffmpeg_stream *strm = (ffmpeg_stream*)s; … … 414 414 415 415 /* API: Start stream. */ 416 static pj_status_t ffmpeg_stream_start(pjmedia_vid_ stream *s)416 static pj_status_t ffmpeg_stream_start(pjmedia_vid_dev_stream *s) 417 417 { 418 418 ffmpeg_stream *strm = (ffmpeg_stream*)s; … … 436 436 437 437 /* API: Get frame from stream */ 438 static pj_status_t ffmpeg_stream_get_frame(pjmedia_vid_ stream *s,438 static pj_status_t ffmpeg_stream_get_frame(pjmedia_vid_dev_stream *s, 439 439 pjmedia_frame *frame) 440 440 { … … 459 459 460 460 /* API: Stop stream. */ 461 static pj_status_t ffmpeg_stream_stop(pjmedia_vid_ stream *s)461 static pj_status_t ffmpeg_stream_stop(pjmedia_vid_dev_stream *s) 462 462 { 463 463 ffmpeg_stream *strm = (ffmpeg_stream*)s; … … 473 473 474 474 /* API: Destroy stream. */ 475 static pj_status_t ffmpeg_stream_destroy(pjmedia_vid_ stream *s)475 static pj_status_t ffmpeg_stream_destroy(pjmedia_vid_dev_stream *s) 476 476 { 477 477 ffmpeg_stream *strm = (ffmpeg_stream*)s;
Note: See TracChangeset
for help on using the changeset viewer.