blob: 01982d36b97a3a935fd7b047ac063866937b65dd [file] [log] [blame]
Sauw Ming6e6c2152010-12-14 13:03:10 +00001/* $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-videodev/videodev_imp.h>
20#include <pj/assert.h>
21#include <pj/log.h>
22#include <pj/os.h>
23
24#if PJMEDIA_VIDEO_DEV_HAS_IOS
25#include "Availability.h"
26#ifdef __IPHONE_4_0
27
28#import <UIKit/UIKit.h>
29#import <AVFoundation/AVFoundation.h>
30
31#define THIS_FILE "ios_dev.c"
32#define DEFAULT_CLOCK_RATE 9000
33#define DEFAULT_WIDTH 480
34#define DEFAULT_HEIGHT 360
35#define DEFAULT_FPS 15
36
37typedef struct ios_fmt_info
38{
39 pjmedia_format_id pjmedia_format;
40 UInt32 ios_format;
41} ios_fmt_info;
42
43static ios_fmt_info ios_fmts[] =
44{
45 {PJMEDIA_FORMAT_BGRA, kCVPixelFormatType_32BGRA} ,
46};
47
48/* qt device info */
49struct ios_dev_info
50{
51 pjmedia_vid_dev_info info;
52};
53
54/* qt factory */
55struct ios_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 ios_dev_info *dev_info;
63};
64
65@interface VOutDelegate: NSObject
66 <AVCaptureVideoDataOutputSampleBufferDelegate>
67{
68@public
69 struct ios_stream *stream;
70}
71@end
72
73/* Video stream. */
74struct ios_stream
75{
76 pjmedia_vid_stream base; /**< Base stream */
77 pjmedia_vid_param param; /**< Settings */
78 pj_pool_t *pool; /**< Memory pool. */
79
80 pjmedia_vid_cb vid_cb; /**< Stream callback. */
81 void *user_data; /**< Application data. */
82
83 pjmedia_rect_size size;
84 pj_uint8_t bpp;
85 unsigned bytes_per_row;
86 unsigned frame_size;
87
88 AVCaptureSession *cap_session;
89 AVCaptureDeviceInput *dev_input;
90 AVCaptureVideoDataOutput *video_output;
91 VOutDelegate *vout_delegate;
92
93 UIImageView *imgView;
94 void *buf;
95};
96
97
98/* Prototypes */
99static pj_status_t ios_factory_init(pjmedia_vid_dev_factory *f);
100static pj_status_t ios_factory_destroy(pjmedia_vid_dev_factory *f);
101static unsigned ios_factory_get_dev_count(pjmedia_vid_dev_factory *f);
102static pj_status_t ios_factory_get_dev_info(pjmedia_vid_dev_factory *f,
103 unsigned index,
104 pjmedia_vid_dev_info *info);
105static pj_status_t ios_factory_default_param(pj_pool_t *pool,
106 pjmedia_vid_dev_factory *f,
107 unsigned index,
108 pjmedia_vid_param *param);
109static pj_status_t ios_factory_create_stream(pjmedia_vid_dev_factory *f,
110 const pjmedia_vid_param *param,
111 const pjmedia_vid_cb *cb,
112 void *user_data,
113 pjmedia_vid_stream **p_vid_strm);
114
115static pj_status_t ios_stream_get_param(pjmedia_vid_stream *strm,
116 pjmedia_vid_param *param);
117static pj_status_t ios_stream_get_cap(pjmedia_vid_stream *strm,
118 pjmedia_vid_dev_cap cap,
119 void *value);
120static pj_status_t ios_stream_set_cap(pjmedia_vid_stream *strm,
121 pjmedia_vid_dev_cap cap,
122 const void *value);
123static pj_status_t ios_stream_start(pjmedia_vid_stream *strm);
124static pj_status_t ios_stream_put_frame(pjmedia_vid_stream *strm,
125 const pjmedia_frame *frame);
126static pj_status_t ios_stream_stop(pjmedia_vid_stream *strm);
127static pj_status_t ios_stream_destroy(pjmedia_vid_stream *strm);
128
129/* Operations */
130static pjmedia_vid_dev_factory_op factory_op =
131{
132 &ios_factory_init,
133 &ios_factory_destroy,
134 &ios_factory_get_dev_count,
135 &ios_factory_get_dev_info,
136 &ios_factory_default_param,
137 &ios_factory_create_stream
138};
139
140static pjmedia_vid_stream_op stream_op =
141{
142 &ios_stream_get_param,
143 &ios_stream_get_cap,
144 &ios_stream_set_cap,
145 &ios_stream_start,
146 NULL,
147 &ios_stream_put_frame,
148 &ios_stream_stop,
149 &ios_stream_destroy
150};
151
152
153/****************************************************************************
154 * Factory operations
155 */
156/*
157 * Init ios_ video driver.
158 */
159pjmedia_vid_dev_factory* pjmedia_ios_factory(pj_pool_factory *pf)
160{
161 struct ios_factory *f;
162 pj_pool_t *pool;
163
164 pool = pj_pool_create(pf, "ios video", 512, 512, NULL);
165 f = PJ_POOL_ZALLOC_T(pool, struct ios_factory);
166 f->pf = pf;
167 f->pool = pool;
168 f->base.op = &factory_op;
169
170 return &f->base;
171}
172
173
174/* API: init factory */
175static pj_status_t ios_factory_init(pjmedia_vid_dev_factory *f)
176{
177 struct ios_factory *qf = (struct ios_factory*)f;
178 struct ios_dev_info *qdi;
179 unsigned i, l;
180
181 /* Initialize input and output devices here */
182 qf->dev_info = (struct ios_dev_info*)
183 pj_pool_calloc(qf->pool, 2,
184 sizeof(struct ios_dev_info));
185
186 qf->dev_count = 0;
187 qdi = &qf->dev_info[qf->dev_count++];
188 pj_bzero(qdi, sizeof(*qdi));
189 strcpy(qdi->info.name, "iOS UIView");
190 strcpy(qdi->info.driver, "iOS");
191 qdi->info.dir = PJMEDIA_DIR_RENDER;
Sauw Mingab494302010-12-17 13:17:23 +0000192 qdi->info.has_callback = PJ_FALSE;
193 qdi->info.caps = PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW;
Sauw Ming6e6c2152010-12-14 13:03:10 +0000194
195 if (NSClassFromString(@"AVCaptureSession")) {
196 qdi = &qf->dev_info[qf->dev_count++];
197 pj_bzero(qdi, sizeof(*qdi));
198 strcpy(qdi->info.name, "iOS AVCapture");
199 strcpy(qdi->info.driver, "iOS");
200 qdi->info.dir = PJMEDIA_DIR_CAPTURE;
201 qdi->info.has_callback = PJ_TRUE;
202 }
203
204 for (i = 0; i < qf->dev_count; i++) {
205 qdi = &qf->dev_info[i];
206 qdi->info.fmt_cnt = PJ_ARRAY_SIZE(ios_fmts);
Sauw Mingab494302010-12-17 13:17:23 +0000207 qdi->info.caps |= PJMEDIA_VID_DEV_CAP_FORMAT;
Sauw Ming6e6c2152010-12-14 13:03:10 +0000208 qdi->info.fmt = (pjmedia_format*)
209 pj_pool_calloc(qf->pool, qdi->info.fmt_cnt,
210 sizeof(pjmedia_format));
211
212 for (l = 0; l < PJ_ARRAY_SIZE(ios_fmts); l++) {
213 pjmedia_format *fmt = &qdi->info.fmt[l];
214 pjmedia_format_init_video(fmt,
215 ios_fmts[l].pjmedia_format,
216 DEFAULT_WIDTH,
217 DEFAULT_HEIGHT,
218 DEFAULT_FPS, 1);
219 }
220 }
221
222 PJ_LOG(4, (THIS_FILE, "iOS video initialized with %d devices",
223 qf->dev_count));
224
225 return PJ_SUCCESS;
226}
227
228/* API: destroy factory */
229static pj_status_t ios_factory_destroy(pjmedia_vid_dev_factory *f)
230{
231 struct ios_factory *qf = (struct ios_factory*)f;
232 pj_pool_t *pool = qf->pool;
233
234 qf->pool = NULL;
235 pj_pool_release(pool);
236
237 return PJ_SUCCESS;
238}
239
240/* API: get number of devices */
241static unsigned ios_factory_get_dev_count(pjmedia_vid_dev_factory *f)
242{
243 struct ios_factory *qf = (struct ios_factory*)f;
244 return qf->dev_count;
245}
246
247/* API: get device info */
248static pj_status_t ios_factory_get_dev_info(pjmedia_vid_dev_factory *f,
249 unsigned index,
250 pjmedia_vid_dev_info *info)
251{
252 struct ios_factory *qf = (struct ios_factory*)f;
253
254 PJ_ASSERT_RETURN(index < qf->dev_count, PJMEDIA_EVID_INVDEV);
255
256 pj_memcpy(info, &qf->dev_info[index].info, sizeof(*info));
257
258 return PJ_SUCCESS;
259}
260
261/* API: create default device parameter */
262static pj_status_t ios_factory_default_param(pj_pool_t *pool,
263 pjmedia_vid_dev_factory *f,
264 unsigned index,
265 pjmedia_vid_param *param)
266{
267 struct ios_factory *qf = (struct ios_factory*)f;
268 struct ios_dev_info *di = &qf->dev_info[index];
269
270 PJ_ASSERT_RETURN(index < qf->dev_count, PJMEDIA_EVID_INVDEV);
271
272 PJ_UNUSED_ARG(pool);
273
274 pj_bzero(param, sizeof(*param));
275 if (di->info.dir & PJMEDIA_DIR_CAPTURE_RENDER) {
276 param->dir = PJMEDIA_DIR_CAPTURE_RENDER;
277 param->cap_id = index;
278 param->rend_id = index;
279 } else if (di->info.dir & PJMEDIA_DIR_CAPTURE) {
280 param->dir = PJMEDIA_DIR_CAPTURE;
281 param->cap_id = index;
282 param->rend_id = PJMEDIA_VID_INVALID_DEV;
283 } else if (di->info.dir & PJMEDIA_DIR_RENDER) {
284 param->dir = PJMEDIA_DIR_RENDER;
285 param->rend_id = index;
286 param->cap_id = PJMEDIA_VID_INVALID_DEV;
287 } else {
288 return PJMEDIA_EVID_INVDEV;
289 }
290
291 param->flags = PJMEDIA_VID_DEV_CAP_FORMAT;
292 param->clock_rate = DEFAULT_CLOCK_RATE;
293 param->frame_rate.num = DEFAULT_FPS;
294 param->frame_rate.denum = 1;
295 pj_memcpy(&param->fmt, &di->info.fmt[0], sizeof(param->fmt));
296
297 return PJ_SUCCESS;
298}
299
300@implementation VOutDelegate
301- (void)update_image
302{
303 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
304
305 /* Create a device-dependent RGB color space */
306 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
307
308 /* Create a bitmap graphics context with the sample buffer data */
309 CGContextRef context =
310 CGBitmapContextCreate(stream->buf, stream->size.w, stream->size.h, 8,
311 stream->bytes_per_row, colorSpace,
312 kCGBitmapByteOrder32Little |
313 kCGImageAlphaPremultipliedFirst);
314
315 /**
316 * Create a Quartz image from the pixel data in the bitmap graphics
317 * context
318 */
319 CGImageRef quartzImage = CGBitmapContextCreateImage(context);
320
321 /* Free up the context and color space */
322 CGContextRelease(context);
323 CGColorSpaceRelease(colorSpace);
324
325 /* Create an image object from the Quartz image */
326 UIImage *image = [UIImage imageWithCGImage:quartzImage scale:1.0
327 orientation:UIImageOrientationRight];
328
329 /* Release the Quartz image */
330 CGImageRelease(quartzImage);
331
Sauw Mingab494302010-12-17 13:17:23 +0000332 [stream->imgView performSelectorOnMainThread:@selector(setImage:)
333 withObject:image waitUntilDone:NO];
Sauw Ming6e6c2152010-12-14 13:03:10 +0000334
335 [pool release];
336}
337
338- (void)captureOutput:(AVCaptureOutput *)captureOutput
339 didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
340 fromConnection:(AVCaptureConnection *)connection
341{
342 pjmedia_frame frame;
343 CVImageBufferRef imageBuffer;
344
345 if (!sampleBuffer)
346 return;
347
348 /* Get a CMSampleBuffer's Core Video image buffer for the media data */
349 imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
350
351 /* Lock the base address of the pixel buffer */
352 CVPixelBufferLockBaseAddress(imageBuffer, 0);
353
354 frame.type = PJMEDIA_TYPE_VIDEO;
355 frame.buf = CVPixelBufferGetBaseAddress(imageBuffer);
356 frame.size = stream->frame_size;
357 frame.bit_info = 0;
358 if (stream->vid_cb.capture_cb)
359 (*stream->vid_cb.capture_cb)(&stream->base, stream->user_data, &frame);
360
361 /* Unlock the pixel buffer */
362 CVPixelBufferUnlockBaseAddress(imageBuffer,0);
363}
364@end
365
366static ios_fmt_info* get_ios_format_info(pjmedia_format_id id)
367{
368 unsigned i;
369
370 for (i = 0; i < PJ_ARRAY_SIZE(ios_fmts); i++) {
371 if (ios_fmts[i].pjmedia_format == id)
372 return &ios_fmts[i];
373 }
374
375 return NULL;
376}
377
378/* API: create stream */
379static pj_status_t ios_factory_create_stream(pjmedia_vid_dev_factory *f,
380 const pjmedia_vid_param *param,
381 const pjmedia_vid_cb *cb,
382 void *user_data,
383 pjmedia_vid_stream **p_vid_strm)
384{
385 struct ios_factory *qf = (struct ios_factory*)f;
386 pj_pool_t *pool;
387 struct ios_stream *strm;
388 pjmedia_video_format_detail *vfd;
389 const pjmedia_video_format_info *vfi;
390 pj_status_t status = PJ_SUCCESS;
391 ios_fmt_info *ifi = get_ios_format_info(param->fmt.id);
392 NSError *error;
393
394 PJ_ASSERT_RETURN(f && param && p_vid_strm, PJ_EINVAL);
395 PJ_ASSERT_RETURN(param->fmt.type == PJMEDIA_TYPE_VIDEO &&
396 param->fmt.detail_type == PJMEDIA_FORMAT_DETAIL_VIDEO,
397 PJ_EINVAL);
398
399 if (!(ifi = get_ios_format_info(param->fmt.id)))
400 return PJMEDIA_EVID_BADFORMAT;
401
402 vfi = pjmedia_get_video_format_info(NULL, param->fmt.id);
403 if (!vfi)
404 return PJMEDIA_EVID_BADFORMAT;
405
406 /* Create and Initialize stream descriptor */
407 pool = pj_pool_create(qf->pf, "ios-dev", 4000, 4000, NULL);
408 PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM);
409
410 strm = PJ_POOL_ZALLOC_T(pool, struct ios_stream);
411 pj_memcpy(&strm->param, param, sizeof(*param));
412 strm->pool = pool;
413 pj_memcpy(&strm->vid_cb, cb, sizeof(*cb));
414 strm->user_data = user_data;
415
416 vfd = pjmedia_format_get_video_format_detail(&strm->param.fmt, PJ_TRUE);
417 pj_memcpy(&strm->size, &vfd->size, sizeof(vfd->size));
418 strm->bpp = vfi->bpp;
419 strm->bytes_per_row = strm->size.w * strm->bpp / 8;
420 strm->frame_size = strm->bytes_per_row * strm->size.h;
421
422 /* Create capture stream here */
423 if (param->dir & PJMEDIA_DIR_CAPTURE) {
424 strm->cap_session = [[AVCaptureSession alloc] init];
425 if (!strm->cap_session) {
426 status = PJ_ENOMEM;
427 goto on_error;
428 }
429 strm->cap_session.sessionPreset = AVCaptureSessionPresetMedium;
430
431 /* Open video device */
432 AVCaptureDevice *videoDevice =
433 [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
434 if (!videoDevice) {
435 status = PJMEDIA_EVID_SYSERR;
436 goto on_error;
437 }
438
439 /* Add the video device to the session as a device input */
440 strm->dev_input = [AVCaptureDeviceInput
441 deviceInputWithDevice:videoDevice
442 error: &error];
443 if (!strm->dev_input) {
444 status = PJMEDIA_EVID_SYSERR;
445 goto on_error;
446 }
447 [strm->cap_session addInput:strm->dev_input];
448
449 strm->video_output = [[[AVCaptureVideoDataOutput alloc] init]
450 autorelease];
451 if (!strm->video_output) {
452 status = PJMEDIA_EVID_SYSERR;
453 goto on_error;
454 }
455 [strm->cap_session addOutput:strm->video_output];
456
Sauw Mingab494302010-12-17 13:17:23 +0000457 /* Configure the video output */
Sauw Ming6e6c2152010-12-14 13:03:10 +0000458 strm->vout_delegate = [VOutDelegate alloc];
459 strm->vout_delegate->stream = strm;
460 dispatch_queue_t queue = dispatch_queue_create("myQueue", NULL);
461 [strm->video_output setSampleBufferDelegate:strm->vout_delegate
462 queue:queue];
463 dispatch_release(queue);
464
465 strm->video_output.videoSettings =
466 [NSDictionary dictionaryWithObjectsAndKeys:
467 [NSNumber numberWithInt:ifi->ios_format],
468 kCVPixelBufferPixelFormatTypeKey,
469 [NSNumber numberWithInt: vfd->size.w],
470 kCVPixelBufferWidthKey,
471 [NSNumber numberWithInt: vfd->size.h],
472 kCVPixelBufferHeightKey, nil];
473 strm->video_output.minFrameDuration = CMTimeMake(vfd->fps.denum,
474 vfd->fps.num);
475 }
476
477 /* Create renderer stream here */
478 if (param->dir & PJMEDIA_DIR_RENDER) {
479 /* Get the main window */
480 UIWindow *window = [[UIApplication sharedApplication] keyWindow];
481
Sauw Mingab494302010-12-17 13:17:23 +0000482 if (param->flags & PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW && param->window)
483 window = param->window;
484
Sauw Ming6e6c2152010-12-14 13:03:10 +0000485 pj_assert(window);
486 strm->imgView = [[UIImageView alloc] initWithFrame:[window bounds]];
487 if (!strm->imgView) {
488 status = PJ_ENOMEM;
489 goto on_error;
490 }
491 [window addSubview:strm->imgView];
492
493 if (!strm->vout_delegate) {
494 strm->vout_delegate = [VOutDelegate alloc];
495 strm->vout_delegate->stream = strm;
496 }
497
498 strm->buf = pj_pool_alloc(pool, strm->frame_size);
499 }
500
501 /* Apply the remaining settings */
502 /*
503 if (param->flags & PJMEDIA_VID_DEV_CAP_INPUT_SCALE) {
504 ios_stream_set_cap(&strm->base,
505 PJMEDIA_VID_DEV_CAP_INPUT_SCALE,
506 &param->fmt);
507 }
508 */
509 /* Done */
510 strm->base.op = &stream_op;
511 *p_vid_strm = &strm->base;
512
513 return PJ_SUCCESS;
514
515on_error:
516 ios_stream_destroy((pjmedia_vid_stream *)strm);
517
518 return status;
519}
520
521/* API: Get stream info. */
522static pj_status_t ios_stream_get_param(pjmedia_vid_stream *s,
523 pjmedia_vid_param *pi)
524{
525 struct ios_stream *strm = (struct ios_stream*)s;
526
527 PJ_ASSERT_RETURN(strm && pi, PJ_EINVAL);
528
529 pj_memcpy(pi, &strm->param, sizeof(*pi));
530
531/* if (ios_stream_get_cap(s, PJMEDIA_VID_DEV_CAP_INPUT_SCALE,
532 &pi->fmt.info_size) == PJ_SUCCESS)
533 {
534 pi->flags |= PJMEDIA_VID_DEV_CAP_INPUT_SCALE;
535 }
536*/
537 return PJ_SUCCESS;
538}
539
540/* API: get capability */
541static pj_status_t ios_stream_get_cap(pjmedia_vid_stream *s,
542 pjmedia_vid_dev_cap cap,
543 void *pval)
544{
545 struct ios_stream *strm = (struct ios_stream*)s;
546
547 PJ_UNUSED_ARG(strm);
548
549 PJ_ASSERT_RETURN(s && pval, PJ_EINVAL);
550
551 if (cap==PJMEDIA_VID_DEV_CAP_INPUT_SCALE)
552 {
553 return PJMEDIA_EVID_INVCAP;
554// return PJ_SUCCESS;
555 } else {
556 return PJMEDIA_EVID_INVCAP;
557 }
558}
559
560/* API: set capability */
561static pj_status_t ios_stream_set_cap(pjmedia_vid_stream *s,
562 pjmedia_vid_dev_cap cap,
563 const void *pval)
564{
565 struct ios_stream *strm = (struct ios_stream*)s;
566
567 PJ_UNUSED_ARG(strm);
568
569 PJ_ASSERT_RETURN(s && pval, PJ_EINVAL);
570
571 if (cap==PJMEDIA_VID_DEV_CAP_INPUT_SCALE)
572 {
573 return PJ_SUCCESS;
574 }
575
576 return PJMEDIA_EVID_INVCAP;
577}
578
579/* API: Start stream. */
580static pj_status_t ios_stream_start(pjmedia_vid_stream *strm)
581{
582 struct ios_stream *stream = (struct ios_stream*)strm;
583
584 PJ_UNUSED_ARG(stream);
585
586 PJ_LOG(4, (THIS_FILE, "Starting qt video stream"));
587
588 if (stream->cap_session) {
589 [stream->cap_session startRunning];
590
591 if (![stream->cap_session isRunning])
592 return PJ_EUNKNOWN;
593 }
594
595 return PJ_SUCCESS;
596}
597
598
599/* API: Put frame from stream */
600static pj_status_t ios_stream_put_frame(pjmedia_vid_stream *strm,
601 const pjmedia_frame *frame)
602{
603 struct ios_stream *stream = (struct ios_stream*)strm;
604 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
605
606 pj_assert(stream->frame_size >= frame->size);
607 pj_memcpy(stream->buf, frame->buf, frame->size);
608 /* Perform video display in a background thread */
609// [stream->vout_delegate update_image];
610 [NSThread detachNewThreadSelector:@selector(update_image)
611 toTarget:stream->vout_delegate withObject:nil];
612
613 [pool release];
614
615 return PJ_SUCCESS;
616}
617
618/* API: Stop stream. */
619static pj_status_t ios_stream_stop(pjmedia_vid_stream *strm)
620{
621 struct ios_stream *stream = (struct ios_stream*)strm;
622
623 PJ_UNUSED_ARG(stream);
624
625 PJ_LOG(4, (THIS_FILE, "Stopping qt video stream"));
626
627 if (stream->cap_session && [stream->cap_session isRunning])
628 [stream->cap_session stopRunning];
629
630 return PJ_SUCCESS;
631}
632
633
634/* API: Destroy stream. */
635static pj_status_t ios_stream_destroy(pjmedia_vid_stream *strm)
636{
637 struct ios_stream *stream = (struct ios_stream*)strm;
638
639 PJ_ASSERT_RETURN(stream != NULL, PJ_EINVAL);
640
641 ios_stream_stop(strm);
642
643 if (stream->imgView) {
644 [stream->imgView removeFromSuperview];
645 [stream->imgView release];
646 stream->imgView = NULL;
647 }
648
649 if (stream->cap_session) {
650 [stream->cap_session release];
651 stream->cap_session = NULL;
652 }
653/* if (stream->dev_input) {
654 [stream->dev_input release];
655 stream->dev_input = NULL;
656 }
657*/
658 if (stream->vout_delegate) {
659 [stream->vout_delegate release];
660 stream->vout_delegate = NULL;
661 }
662/* if (stream->video_output) {
663 [stream->video_output release];
664 stream->video_output = NULL;
665 }
666*/
667
668 pj_pool_release(stream->pool);
669
670 return PJ_SUCCESS;
671}
672
673#endif
674#endif /* PJMEDIA_VIDEO_DEV_HAS_IOS */