Some questions about pjsip 2.0-alpha on iOS without SDL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I tried to use pjsip 2.0-alpha on iOS without SDL.
I made some modification for example in ios_factory_init function. Like 
that the function find all capture devices (see below for the code).

However I have some questions:
     - iOS has native capture preview (Ticket 1333, and 1340) with 
AVCaptureVideoPreviewLayer class. Do you think we should add a new entry 
in ios_factory struct during th initialization (ios_factory_init) ?
     - iOS has some capture setting presets (192x144, 480x360, 640x480, 
1280x720). Generally h263 uses the 352x288 resolution). Unfortunately 
ios_factory_create_stream function creates a stream with the 352x288 
resolution, but the callback gets images with 480x360 size. Where do you 
think the resampling should be done ?
         + In the callback ? In this case, do I use 
pjmedia_converter_convert function ?
         + In pjmedia_XXX function ? How can I force the resolution of 
the stream ? And where do I add a new converter ?

Thanks in advance for your answer

Best Regards

Samuel

CODE (3 modifications)

1/ Add a new field
/* ios device info */
struct ios_dev_info
{
     pjmedia_vid_dev_info     info;
     char                     dev_id[128]; // Add this field to manage 
the capture device
};

2/ Use the new field
In ios_factory_create_stream funvtion, I replaced the creation of 
AVCaptureDevice by

     /* Open video device */
     AVCaptureDevice *videoDevice =
             [AVCaptureDevice deviceWithUniqueID:
                              [NSString stringWithCString:
                                        qf->dev_info[param->cap_id].dev_id
                                        encoding: [NSString 
defaultCStringEncoding]]];


3/ Initialize the new field
/* API: init factory */
static pj_status_t ios_factory_init(pjmedia_vid_dev_factory *f)
{
     struct ios_factory *qf = (struct ios_factory*)f;
     struct ios_dev_info *qdi;
     unsigned i, l, dev_count = 0;

     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

     NSArray *devices = [AVCaptureDevice 
devicesWithMediaType:AVMediaTypeVideo];
     dev_count = 1 + [devices count];

     /* Initialize input and output devices here */
     qf->dev_info = (struct ios_dev_info*)
            pj_pool_calloc(qf->pool, dev_count,
                   sizeof(struct ios_dev_info));

     qf->dev_count = 0;
     qdi = &qf->dev_info[qf->dev_count++];
     pj_bzero(qdi, sizeof(*qdi));
     strcpy(qdi->info.name, "iOS UIView");
     strcpy(qdi->info.driver, "iOS");
     qdi->info.dir = PJMEDIA_DIR_RENDER;
     qdi->info.has_callback = PJ_FALSE;
     qdi->info.caps = PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW;

     for (AVCaptureDevice *device in devices)
     {
         qdi = &qf->dev_info[qf->dev_count++];
         pj_bzero(qdi, sizeof(*qdi));
         [[device localizedName] getCString:qdi->info.name
                                  maxLength:sizeof(qdi->info.name)
                                   encoding:[NSString 
defaultCStringEncoding]];
         [[device uniqueID] getCString:qdi->dev_id
                             maxLength:sizeof(qdi->dev_id)
                              encoding:[NSString defaultCStringEncoding]];
         strcpy(qdi->info.driver, "iOS");
         qdi->info.dir = PJMEDIA_DIR_CAPTURE;
         qdi->info.has_callback = PJ_TRUE;
     }

     [pool drain];

     for (i = 0; i < qf->dev_count; i++) {
     qdi = &qf->dev_info[i];
     qdi->info.fmt_cnt = PJ_ARRAY_SIZE(ios_fmts);
     qdi->info.caps |= PJMEDIA_VID_DEV_CAP_FORMAT /*|
         PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE | 
PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION*/;

     for (l = 0; l < PJ_ARRAY_SIZE(ios_fmts); l++) {
         pjmedia_format *fmt = &qdi->info.fmt[l];
         pjmedia_format_init_video(fmt,
                       ios_fmts[l].pjmedia_format,
                       DEFAULT_WIDTH,
                       DEFAULT_HEIGHT,
                       DEFAULT_FPS, 1);
     }
     }

     PJ_LOG(4, (THIS_FILE, "iOS video initialized with %d devices",
            qf->dev_count));

     return PJ_SUCCESS;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20110829/a9eef34c/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux