Beispiel #1
0
bool utox_video_change_device(uint16_t device_number) {
    pthread_mutex_lock(&video_thread_lock);

    static bool _was_active = false;

    if (!device_number) {
        video_device_current = 0;
        if (video_active) {
            video_device_stop();
            close_video_device(video_device[video_device_current]);
            if (settings.video_preview) {
                settings.video_preview = false;
                postmessage_utox(AV_CLOSE_WINDOW, 0, 0, NULL);
            }
        }
        LOG_TRACE("uToxVideo", "Disabled Video device (none)" );
        pthread_mutex_unlock(&video_thread_lock);
        return false;
    }

    if (video_active) {
        _was_active = true;
        video_device_stop();
        close_video_device(video_device[video_device_current]);
    } else {
        _was_active = false;
    }

    video_device_current = device_number;

    video_device_init(video_device[device_number]);

    if (_was_active) {
        LOG_TRACE("uToxVideo", "Trying to restart video with new device..." );
        if (!video_device_start()) {
            LOG_ERR("uToxVideo", "Error, unable to start new device...");
            if (settings.video_preview) {
                settings.video_preview = false;
                postmessage_utox(AV_CLOSE_WINDOW, 0, 0, NULL);
            }

            pthread_mutex_unlock(&video_thread_lock);
            return false;
        }
        pthread_mutex_unlock(&video_thread_lock);
        return true;
    } else {
        /* Just grab the new frame size */
        close_video_device(video_device[video_device_current]);
    }
    pthread_mutex_unlock(&video_thread_lock);
    return false;
}
Beispiel #2
0
// Populates the video device dropdown.
static void init_video_devices(void) {
    // Add always-present null video input device.
    utox_video_append_device(NULL, 1, (void *)STR_VIDEO_IN_NONE, 1);

    // select a video device (autodectect)
    video_device_current = native_video_detect();

    if (video_device_current) {
        // open the video device to get some info e.g. frame size
        // close it afterwards to not block the device while it is not used
        if (video_device_init(video_device[video_device_current])) {
            close_video_device(video_device[video_device_current]);
        }
    }
}
int init_isil_avSync_dev(isil_avSync_dev_t *dev, int bus_id, int chip_id, int inode_id, int id)
{
    int	ret = ISIL_ERR;
    if(dev != NULL){
        dev->bus_id = bus_id;
        dev->chip_id = chip_id;
        dev->dev_inode_id = inode_id;
        dev->id = id;
        sprintf(dev->name, "isil_avSync_dev_%d", dev->dev_inode_id);
        video_device_init(dev);
        //init_MUTEX(&dev->sem);
        sema_init(&dev->sem, 1);
        atomic_set(&dev->opened_flags, 0);
        init_waitqueue_head(&dev->wait_poll);

        dev->h264_master_encode_driver = NULL;
        dev->h264_sub_encode_driver = NULL;
        dev->jpeg_encode_driver = NULL;
        dev->audio_encode_driver = NULL;
        dev->audio_decode_driver = NULL;

        ret = init_avSync_frame_buf_pool(&dev->device_buf_pool);
        if(ret == ISIL_OK){
            init_avSync_frame_queue(&dev->avSync_frame_queue);
            ISIL_DBG(ISIL_DBG_DEBUG, "register video device minor %d\n", dev->dev_inode_id);
#if defined(X86_PLATFORM) || defined(HISILICON_PLATFORM)
            ret = 0;
#elif defined(POWERPC_PLATFORM)
            ret = video_register_device_index(&dev->vfd, VFL_TYPE_GRABBER, dev->dev_inode_id, dev->dev_inode_id);
#endif
            if(ret) {
                ISIL_DBG(ISIL_DBG_ERR, "register video device failed %d\n", ret);
            }
        }
    }
    return ret;
}
Beispiel #4
0
bool utox_video_start(bool preview) {
    if (video_active) {
        LOG_NOTE("uToxVideo", "video already running" );
        return true;
    }

    if (!video_device_current) {
        LOG_NOTE("uToxVideo", "Not starting device None" );
        return false;
    }

    if (preview) {
        settings.video_preview = true;
    }

    if (video_device_init(video_device[video_device_current]) && video_device_start()) {
        video_active = true;
        LOG_NOTE("uToxVideo", "started video" );
        return true;
    }

    LOG_ERR("uToxVideo", "Unable to start video.");
    return false;
}