Debian Codegraph @

Xpjproject/pjmedia/src/pjmedia-videodev/avi_dev.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 #include <pjmedia-videodev/videodev_imp.h>
19 #include <pjmedia-videodev/avi_dev.h>
20 #include <pj/assert.h>
21 #include <pj/log.h>
22 #include <pj/os.h>
23 #include <pj/rand.h>
24 #include <pjmedia/vid_codec.h>
25
26 #if defined(PJMEDIA_VIDEO_DEV_HAS_AVI) && PJMEDIA_VIDEO_DEV_HAS_AVI != 0 && \
27 defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
28
29 #define THIS_FILE "avi_dev.c"
30 #define DRIVER_NAME "AVIDev"
31 #define DEFAULT_CLOCK_RATE 90000
32 #define DEFAULT_WIDTH 640
33 #define DEFAULT_HEIGHT 480
34 #define DEFAULT_FPS 25
35
36 typedef struct avi_dev_strm avi_dev_strm;
37
38 /* avi_ device info */
39 struct avi_dev_info
40 {
41 pjmedia_vid_dev_info info;
42
43 pj_pool_t *pool;
44 pj_str_t fpath;
45 pj_str_t title;
46 pjmedia_avi_streams *avi;
47 pjmedia_port *vid;
48 avi_dev_strm *strm;
49 pjmedia_vid_codec *codec;
50 pj_uint8_t *enc_buf;
51 pj_size_t enc_buf_size;
52 };
53
54 /* avi_ factory */
55 struct avi_factory
56 {
57 pjmedia_vid_dev_factory base;
58 pj_pool_t *pool;
59 pj_pool_factory *pf;
60
61 unsigned dev_count;
62 struct avi_dev_info *dev_info;
63 };
64
65 /* Video stream. */
66 struct avi_dev_strm
67 {
68 pjmedia_vid_dev_stream base; /**< Base stream */
69 pjmedia_vid_dev_param param; /**< Settings */
70 pj_pool_t *pool; /**< Memory pool. */
71 struct avi_dev_info *adi;
72
73 pjmedia_vid_dev_cb vid_cb; /**< Stream callback. */
74 void *user_data; /**< Application data. */
75 };
76
77
78 /* Prototypes */
79 static pj_status_t avi_factory_init(pjmedia_vid_dev_factory *f);
80 static pj_status_t avi_factory_destroy(pjmedia_vid_dev_factory *f);
81 static pj_status_t avi_factory_refresh(pjmedia_vid_dev_factory *f);
82 static unsigned avi_factory_get_dev_count(pjmedia_vid_dev_factory *f);
83 static pj_status_t avi_factory_get_dev_info(pjmedia_vid_dev_factory *f,
84 unsigned index,
85 pjmedia_vid_dev_info *info);
86 static pj_status_t avi_factory_default_param(pj_pool_t *pool,
87 pjmedia_vid_dev_factory *f,
88 unsigned index,
89 pjmedia_vid_dev_param *param);
90 static pj_status_t avi_factory_create_stream(
91 pjmedia_vid_dev_factory *f,
92 pjmedia_vid_dev_param *param,
93 const pjmedia_vid_dev_cb *cb,
94 void *user_data,
95 pjmedia_vid_dev_stream **p_vid_strm);
96
97 static pj_status_t avi_dev_strm_get_param(pjmedia_vid_dev_stream *strm,
98 pjmedia_vid_dev_param *param);
99 static pj_status_t avi_dev_strm_get_cap(pjmedia_vid_dev_stream *strm,
100 pjmedia_vid_dev_cap cap,
101 void *value);
102 static pj_status_t avi_dev_strm_set_cap(pjmedia_vid_dev_stream *strm,
103 pjmedia_vid_dev_cap cap,
104 const void *value);
105 static pj_status_t avi_dev_strm_get_frame(pjmedia_vid_dev_stream *strm,
106 pjmedia_frame *frame);
107 static pj_status_t avi_dev_strm_start(pjmedia_vid_dev_stream *strm);
108 static pj_status_t avi_dev_strm_stop(pjmedia_vid_dev_stream *strm);
109 static pj_status_t avi_dev_strm_destroy(pjmedia_vid_dev_stream *strm);
110
111 static void reset_dev_info(struct avi_dev_info *adi);
112
113 /* Operations */
114 static pjmedia_vid_dev_factory_op factory_op =
115 {
116 &avi_factory_init,
117 &avi_factory_destroy,
118 &avi_factory_get_dev_count,
119 &avi_factory_get_dev_info,
120 &avi_factory_default_param,
121 &avi_factory_create_stream,
122 &avi_factory_refresh
123 };
124
125 static pjmedia_vid_dev_stream_op stream_op =
126 {
127 &avi_dev_strm_get_param,
128 &avi_dev_strm_get_cap,
129 &avi_dev_strm_set_cap,
130 &avi_dev_strm_start,
131 &avi_dev_strm_get_frame,
132 NULL,
133 &avi_dev_strm_stop,
134 &avi_dev_strm_destroy
135 };
136
137
138 /****************************************************************************
139 * Factory operations
140 */
141
142 /* API */
143 PJ_DEF(pj_status_t) pjmedia_avi_dev_create_factory(
144 pj_pool_factory *pf,
145 unsigned max_dev,
146 pjmedia_vid_dev_factory **p_ret)
147 {
148 struct avi_factory *cf;
149 pj_pool_t *pool;
150 pj_status_t status;
151
152 pool = pj_pool_create(pf, "avidevfc%p", 512, 512, NULL);
153 cf = PJ_POOL_ZALLOC_T(pool, struct avi_factory);
154 cf->pf = pf;
155 cf->pool = pool;
156 cf->dev_count = max_dev;
157 cf->base.op = &factory_op;
158
159 cf->dev_info = (struct avi_dev_info*)
160 pj_pool_calloc(cf->pool, cf->dev_count,
161 sizeof(struct avi_dev_info));
162
163 if (p_ret) {
164 *p_ret = &cf->base;
165 }
166
167 status = pjmedia_vid_register_factory(NULL, &cf->base);
168 if (status != PJ_SUCCESS)
169 return status;
170
171 PJ_LOG(4, (THIS_FILE, "AVI dev factory created with %d virtual device(s)",
172 cf->dev_count));
173
174 return PJ_SUCCESS;
175 }
176
177 /* API: init factory */
178 static pj_status_t avi_factory_init(pjmedia_vid_dev_factory *f)
179 {
180 struct avi_factory *cf = (struct avi_factory*)f;
181 unsigned i;
182
183 for (i=0; i<cf->dev_count; ++i) {
184 reset_dev_info(&cf->dev_info[i]);
185 }
186
187 return PJ_SUCCESS;
188 }
189
190 /* API: destroy factory */
191 static pj_status_t avi_factory_destroy(pjmedia_vid_dev_factory *f)
192 {
193 struct avi_factory *cf = (struct avi_factory*)f;
194
195 pj_pool_safe_release(&cf->pool);
196
197 return PJ_SUCCESS;
198 }
199
200 /* API: refresh the list of devices */
201 static pj_status_t avi_factory_refresh(pjmedia_vid_dev_factory *f)
202 {
203 PJ_UNUSED_ARG(f);
204 return PJ_SUCCESS;
205 }
206
207 /* API: get number of devices */
208 static unsigned avi_factory_get_dev_count(pjmedia_vid_dev_factory *f)
209 {
210 struct avi_factory *cf = (struct avi_factory*)f;
211 return cf->dev_count;
212 }
213
214 /* API: get device info */
215 static pj_status_t avi_factory_get_dev_info(pjmedia_vid_dev_factory *f,
216 unsigned index,
217 pjmedia_vid_dev_info *info)
218 {
219 struct avi_factory *cf = (struct avi_factory*)f;
220
221 PJ_ASSERT_RETURN(index < cf->dev_count, PJMEDIA_EVID_INVDEV);
222
223 pj_memcpy(info, &cf->dev_info[index].info, sizeof(*info));
224
225 return PJ_SUCCESS;
226 }
227
228 /* API: create default device parameter */
229 static pj_status_t avi_factory_default_param(pj_pool_t *pool,
230 pjmedia_vid_dev_factory *f,
231 unsigned index,
232 pjmedia_vid_dev_param *param)
233 {
234 struct avi_factory *cf = (struct avi_factory*)f;
235 struct avi_dev_info *di = &cf->dev_info[index];
236
237 PJ_ASSERT_RETURN(index < cf->dev_count, PJMEDIA_EVID_INVDEV);
238
239 PJ_UNUSED_ARG(pool);
240
241 pj_bzero(param, sizeof(*param));
242 param->dir = PJMEDIA_DIR_CAPTURE;
243 param->cap_id = index;
244 param->rend_id = PJMEDIA_VID_INVALID_DEV;
245 param->flags = PJMEDIA_VID_DEV_CAP_FORMAT;
246 param->clock_rate = DEFAULT_CLOCK_RATE;
247 pj_memcpy(&param->fmt, &di->info.fmt[0], sizeof(param->fmt));
248
249 return PJ_SUCCESS;
250 }
251
252 /* reset dev info */
253 static void reset_dev_info(struct avi_dev_info *adi)
254 {
255 /* Close avi streams */
256 if (adi->avi) {
257 unsigned i, cnt;
258
259 cnt = pjmedia_avi_streams_get_num_streams(adi->avi);
260 for (i=0; i<cnt; ++i) {
261 pjmedia_avi_stream *as;
262
263 as = pjmedia_avi_streams_get_stream(adi->avi, i);
264 if (as) {
265 pjmedia_port *port;
266 port = pjmedia_avi_stream_get_port(as);
267 pjmedia_port_destroy(port);
268 }
269 }
270 adi->avi = NULL;
271 }
272
273 if (adi->codec) {
274 pjmedia_vid_codec_close(adi->codec);
275 adi->codec = NULL;
276 }
277
278 if (adi->pool)
279 pj_pool_release(adi->pool);
280
281 pj_bzero(adi, sizeof(*adi));
282
283 /* Fill up with *dummy" device info */
284 pj_ansi_strxcpy(adi->info.name, "AVI Player", sizeof(adi->info.name));
285 pj_ansi_strxcpy(adi->info.driver, DRIVER_NAME,
286 sizeof(adi->info.driver));
287 adi->info.dir = PJMEDIA_DIR_CAPTURE;
288 adi->info.has_callback = PJ_FALSE;
289 }
290
291 /* API: release resources */
292 PJ_DEF(pj_status_t) pjmedia_avi_dev_free(pjmedia_vid_dev_index id)
293 {
294 pjmedia_vid_dev_factory *f;
295 struct avi_factory *cf;
296 unsigned local_idx;
297 struct avi_dev_info *adi;
298 pj_status_t status;
299
300 /* Lookup the factory and local device index */
301 status = pjmedia_vid_dev_get_local_index(id, &f, &local_idx);
302 if (status != PJ_SUCCESS)
303 return status;
304
305 /* The factory must be AVI factory */
306 PJ_ASSERT_RETURN(f->op->init == &avi_factory_init, PJMEDIA_EVID_INVDEV);
307 cf = (struct avi_factory*)f;
308
309 /* Device index should be valid */
310 PJ_ASSERT_RETURN(local_idx <= cf->dev_count, PJ_EBUG);
311 adi = &cf->dev_info[local_idx];
312
313 /* Cannot configure if stream is running */
314 if (adi->strm)
315 return PJ_EBUSY;
316
317 /* Reset */
318 reset_dev_info(adi);
319 return PJ_SUCCESS;
320 }
321
322 /* API: get param */
323 PJ_DEF(pj_status_t) pjmedia_avi_dev_get_param(pjmedia_vid_dev_index id,
324 pjmedia_avi_dev_param *prm)
325 {
326 pjmedia_vid_dev_factory *f;
327 struct avi_factory *cf;
328 unsigned local_idx;
329 struct avi_dev_info *adi;
330 pj_status_t status;
331
332 /* Lookup the factory and local device index */
333 status = pjmedia_vid_dev_get_local_index(id, &f, &local_idx);
334 if (status != PJ_SUCCESS)
335 return status;
336
337 /* The factory must be factory */
338 PJ_ASSERT_RETURN(f->op->init == &avi_factory_init, PJMEDIA_EVID_INVDEV);
339 cf = (struct avi_factory*)f;
340
341 /* Device index should be valid */
342 PJ_ASSERT_RETURN(local_idx <= cf->dev_count, PJ_EBUG);
343 adi = &cf->dev_info[local_idx];
344
345 pj_bzero(prm, sizeof(*prm));
346 prm->path = adi->fpath;
347 prm->title = adi->title;
348 prm->avi_streams = adi->avi;
349
350 return PJ_SUCCESS;
351 }
352
353 PJ_DEF(void) pjmedia_avi_dev_param_default(pjmedia_avi_dev_param *p)
354 {
355 pj_bzero(p, sizeof(*p));
356 }
357
358 /* API: configure the AVI */
359 PJ_DEF(pj_status_t) pjmedia_avi_dev_alloc( pjmedia_vid_dev_factory *f,
360 pjmedia_avi_dev_param *p,
361 pjmedia_vid_dev_index *p_id)
362 {
363 pjmedia_vid_dev_index id;
364 struct avi_factory *cf = (struct avi_factory*)f;
365 unsigned local_idx;
366 struct avi_dev_info *adi = NULL;
367 pjmedia_format avi_fmt;
368 const pjmedia_video_format_info *vfi;
369 pj_status_t status;
370
371 PJ_ASSERT_RETURN(f && p && p_id, PJ_EINVAL);
372
373 if (p_id)
374 *p_id = PJMEDIA_VID_INVALID_DEV;
375
376 /* Get a free dev */
377 for (local_idx=0; local_idx<cf->dev_count; ++local_idx) {
378 if (cf->dev_info[local_idx].avi == NULL) {
379 adi = &cf->dev_info[local_idx];
380 break;
381 }
382 }
383
384 if (!adi)
385 return PJ_ETOOMANY;
386
387 /* Convert local ID to global id */
388 status = pjmedia_vid_dev_get_global_index(&cf->base, local_idx, &id);
389 if (status != PJ_SUCCESS)
390 return status;
391
392 /* Reset */
393 if (adi->pool) {
394 pj_pool_release(adi->pool);
395 }
396 pj_bzero(adi, sizeof(*adi));
397
398 /* Reinit */
399 PJ_ASSERT_RETURN(p->path.slen, PJ_EINVAL);
400 adi->pool = pj_pool_create(cf->pf, "avidi%p", 512, 512, NULL);
401 if (!adi->pool) {
402 status = PJ_ENOMEM;
403 goto on_error;
404 }
405
406 /* Open the AVI */
407 pj_strdup_with_null(adi->pool, &adi->fpath, &p->path);
408 status = pjmedia_avi_player_create_streams(adi->pool, adi->fpath.ptr, 0,
409 &adi->avi);
410 if (status != PJ_SUCCESS) {
411 goto on_error;
412 }
413
414 adi->vid = pjmedia_avi_streams_get_stream_by_media(adi->avi, 0,
415 PJMEDIA_TYPE_VIDEO);
416 if (!adi->vid) {
417 status = PJMEDIA_EVID_BADFORMAT;
418 PJ_LOG(4,(THIS_FILE, "Error: cannot find video in AVI %s",
419 adi->fpath.ptr));
420 goto on_error;
421 }
422
423 pjmedia_format_copy(&avi_fmt, &adi->vid->info.fmt);
424 vfi = pjmedia_get_video_format_info(NULL, avi_fmt.id);
425 /* Check whether the frame is encoded. */
426 if (!vfi || vfi->bpp == 0) {
427 /* Yes, prepare codec */
428 const pjmedia_vid_codec_info *codec_info;
429 pjmedia_vid_codec_param codec_param;
430 pjmedia_video_apply_fmt_param vafp;
431
432 /* Lookup codec */
433 status = pjmedia_vid_codec_mgr_get_codec_info2(NULL,
434 avi_fmt.id,
435 &codec_info);
436 if (status != PJ_SUCCESS || !codec_info)
437 goto on_error;
438
439 status = pjmedia_vid_codec_mgr_get_default_param(NULL, codec_info,
440 &codec_param);
441 if (status != PJ_SUCCESS)
442 goto on_error;
443
444 /* Open codec */
445 status = pjmedia_vid_codec_mgr_alloc_codec(NULL, codec_info,
446 &adi->codec);
447 if (status != PJ_SUCCESS)
448 goto on_error;
449
450 status = pjmedia_vid_codec_init(adi->codec, adi->pool);
451 if (status != PJ_SUCCESS)
452 goto on_error;
453
454 codec_param.dir = PJMEDIA_DIR_DECODING;
455 codec_param.packing = PJMEDIA_VID_PACKING_WHOLE;
456 status = pjmedia_vid_codec_open(adi->codec, &codec_param);
457 if (status != PJ_SUCCESS)
458 goto on_error;
459
460 /* Allocate buffer */
461 avi_fmt.id = codec_info->dec_fmt_id[0];
462 vfi = pjmedia_get_video_format_info(NULL, avi_fmt.id);
463 pj_bzero(&vafp, sizeof(vafp));
464 vafp.size = avi_fmt.det.vid.size;
465 status = vfi->apply_fmt(vfi, &vafp);
466 if (status != PJ_SUCCESS)
467 goto on_error;
468
469 adi->enc_buf = pj_pool_alloc(adi->pool, vafp.framebytes);
470 adi->enc_buf_size = vafp.framebytes;
471 }
472
473 /* Calculate title */
474 if (p->title.slen) {
475 pj_strdup_with_null(adi->pool, &adi->title, &p->title);
476 } else {
477 char *start = p->path.ptr + p->path.slen;
478 pj_str_t tmp;
479
480 while (start >= p->path.ptr) {
481 if (*start == '/' || *start == '\\')
482 break;
483 --start;
484 }
485 tmp.ptr = start + 1;
486 tmp.slen = p->path.ptr + p->path.slen - tmp.ptr;
487 pj_strdup_with_null(adi->pool, &adi->title, &tmp);
488 }
489
490 /* Init device info */
491 pj_ansi_strxcpy(adi->info.name, adi->title.ptr,
492 sizeof(adi->info.name));
493 pj_ansi_strxcpy(adi->info.driver, DRIVER_NAME,
494 sizeof(adi->info.driver));
495 adi->info.dir = PJMEDIA_DIR_CAPTURE;
496 adi->info.has_callback = PJ_FALSE;
497
498 adi->info.caps = PJMEDIA_VID_DEV_CAP_FORMAT;
499 adi->info.fmt_cnt = 1;
500 pjmedia_format_copy(&adi->info.fmt[0], &avi_fmt);
501
502 /* Set out vars */
503 if (p_id)
504 *p_id = id;
505 p->avi_streams = adi->avi;
506 if (p->title.slen == 0)
507 p->title = adi->title;
508
509 return PJ_SUCCESS;
510
511 on_error:
512 if (adi->codec) {
513 pjmedia_vid_codec_close(adi->codec);
514 adi->codec = NULL;
515 }
516 if (adi->pool) {
517 pj_pool_release(adi->pool);
518 adi->pool = NULL;
519 }
520 pjmedia_avi_dev_free(id);
521 return status;
522 }
523
524
525 /* API: create stream */
526 static pj_status_t avi_factory_create_stream(
527 pjmedia_vid_dev_factory *f,
528 pjmedia_vid_dev_param *param,
529 const pjmedia_vid_dev_cb *cb,
530 void *user_data,
531 pjmedia_vid_dev_stream **p_vid_strm)
532 {
533 struct avi_factory *cf = (struct avi_factory*)f;
534 pj_pool_t *pool = NULL;
535 struct avi_dev_info *adi;
536 struct avi_dev_strm *strm;
537
538 PJ_ASSERT_RETURN(f && param && p_vid_strm, PJ_EINVAL);
539 PJ_ASSERT_RETURN(param->fmt.type == PJMEDIA_TYPE_VIDEO &&
540 param->fmt.detail_type == PJMEDIA_FORMAT_DETAIL_VIDEO &&
541 param->dir == PJMEDIA_DIR_CAPTURE,
542 PJ_EINVAL);
543
544 /* Device must have been configured with pjmedia_avi_dev_set_param() */
545 adi = &cf->dev_info[param->cap_id];
546 PJ_ASSERT_RETURN(adi->avi != NULL, PJ_EINVALIDOP);
547
548 /* Cannot create while stream is already active */
549 PJ_ASSERT_RETURN(adi->strm==NULL, PJ_EINVALIDOP);
550
551 /* Create and initialize basic stream descriptor */
552 pool = pj_pool_create(cf->pf, "avidev%p", 512, 512, NULL);
553 PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM);
554
555 strm = PJ_POOL_ZALLOC_T(pool, struct avi_dev_strm);
556 pj_memcpy(&strm->param, param, sizeof(*param));
557 strm->pool = pool;
558 pj_memcpy(&strm->vid_cb, cb, sizeof(*cb));
559 strm->user_data = user_data;
560 strm->adi = adi;
561
562 pjmedia_format_copy(&param->fmt, &adi->info.fmt[0]);
563
564 /* Done */
565 strm->base.op = &stream_op;
566 adi->strm = strm;
567 *p_vid_strm = &strm->base;
568
569 return PJ_SUCCESS;
570 }
571
572 /* API: Get stream info. */
573 static pj_status_t avi_dev_strm_get_param(pjmedia_vid_dev_stream *s,
574 pjmedia_vid_dev_param *pi)
575 {
576 struct avi_dev_strm *strm = (struct avi_dev_strm*)s;
577
578 PJ_ASSERT_RETURN(strm && pi, PJ_EINVAL);
579
580 pj_memcpy(pi, &strm->param, sizeof(*pi));
581
582 return PJ_SUCCESS;
583 }
584
585 /* API: get capability */
586 static pj_status_t avi_dev_strm_get_cap(pjmedia_vid_dev_stream *s,
587 pjmedia_vid_dev_cap cap,
588 void *pval)
589 {
590 struct avi_dev_strm *strm = (struct avi_dev_strm*)s;
591
592 PJ_UNUSED_ARG(strm);
593 PJ_UNUSED_ARG(cap);
594 PJ_UNUSED_ARG(pval);
595
596 PJ_ASSERT_RETURN(s && pval, PJ_EINVAL);
597
598 return PJMEDIA_EVID_INVCAP;
599 }
600
601 /* API: set capability */
602 static pj_status_t avi_dev_strm_set_cap(pjmedia_vid_dev_stream *s,
603 pjmedia_vid_dev_cap cap,
604 const void *pval)
605 {
606 struct avi_dev_strm *strm = (struct avi_dev_strm*)s;
607
608 PJ_UNUSED_ARG(strm);
609 PJ_UNUSED_ARG(cap);
610 PJ_UNUSED_ARG(pval);
611
612 PJ_ASSERT_RETURN(s && pval, PJ_EINVAL);
613
614 return PJMEDIA_EVID_INVCAP;
615 }
616
617 /* API: Get frame from stream */
618 static pj_status_t avi_dev_strm_get_frame(pjmedia_vid_dev_stream *strm,
619 pjmedia_frame *frame)
620 {
621 struct avi_dev_strm *stream = (struct avi_dev_strm*)strm;
622
623 if (stream->adi->codec) {
624 pjmedia_frame enc_frame;
625 pj_status_t status;
626
627 enc_frame.buf = stream->adi->enc_buf;
628 enc_frame.size = stream->adi->enc_buf_size;
629 status = pjmedia_port_get_frame(stream->adi->vid, &enc_frame);
630 if (status != PJ_SUCCESS)
631 return status;
632
633 return pjmedia_vid_codec_decode(stream->adi->codec, 1, &enc_frame,
634 (unsigned)frame->size, frame);
635 } else {
636 return pjmedia_port_get_frame(stream->adi->vid, frame);
637 }
638 }
639
640 /* API: Start stream. */
641 static pj_status_t avi_dev_strm_start(pjmedia_vid_dev_stream *strm)
642 {
643 struct avi_dev_strm *stream = (struct avi_dev_strm*)strm;
644
645 PJ_UNUSED_ARG(stream);
646
647 PJ_LOG(4, (THIS_FILE, "Starting avi video stream"));
648
649 return PJ_SUCCESS;
650 }
651
652 /* API: Stop stream. */
653 static pj_status_t avi_dev_strm_stop(pjmedia_vid_dev_stream *strm)
654 {
655 struct avi_dev_strm *stream = (struct avi_dev_strm*)strm;
656
657 PJ_UNUSED_ARG(stream);
658
659 PJ_LOG(4, (THIS_FILE, "Stopping avi video stream"));
660
661 return PJ_SUCCESS;
662 }
663
664
665 /* API: Destroy stream. */
666 static pj_status_t avi_dev_strm_destroy(pjmedia_vid_dev_stream *strm)
667 {
668 struct avi_dev_strm *stream = (struct avi_dev_strm*)strm;
669
670 PJ_ASSERT_RETURN(stream != NULL, PJ_EINVAL);
671
672 avi_dev_strm_stop(strm);
673
674 stream->adi->strm = NULL;
675 stream->adi = NULL;
676 pj_pool_release(stream->pool);
677
678 return PJ_SUCCESS;
679 }
680
681 #endif /* PJMEDIA_VIDEO_DEV_HAS_AVI */