Beispiel #1
0
HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(
    IDeckLinkVideoInputFrame *videoFrame, IDeckLinkAudioInputPacket *audioFrame)
{

    frameCount++;

    // Handle Video Frame
    if (videoFrame) {
        BMDTimeValue frameTime;
        BMDTimeValue frameDuration;
        int64_t pts;
        videoFrame->GetStreamTime(&frameTime, &frameDuration,
                                  video_st->time_base.den);

        pts = frameTime / video_st->time_base.num;

        if (initial_video_pts == AV_NOPTS_VALUE) {
            initial_video_pts = pts;
        }

        pts -= initial_video_pts;

        write_video_packet(videoFrame, pts, frameDuration);

        if (serial_fd > 0) {
            char line[8] = {0};
            int count = read(serial_fd, line, 7);
            if (count > 0)
                fprintf(stderr, "read %d bytes: %s  \n", count, line);
            else line[0] = ' ';
            write_data_packet(line, 7, pts);
        }

        if (wallclock) {
            int64_t t = av_gettime();
            char line[20];
            snprintf(line, sizeof(line), "%" PRId64, t);
            write_data_packet(line, strlen(line), pts);
        }
    }

    // Handle Audio Frame
    if (audioFrame)
        write_audio_packet(audioFrame);


    return S_OK;
}
Beispiel #2
0
static void
descriptor_callback(HANDLE hub, ULONG port, USHORT deviceAddress,
                    PUSB_DEVICE_DESCRIPTOR desc, void *context)
{
    descriptor_callback_context *ctx = (descriptor_callback_context *)context;
    PUSB_DESCRIPTOR_REQUEST request;

    if (!USBPcapIsDeviceFiltered(ctx->addresses, deviceAddress))
    {
        return;
    }

    write_setup_packet(ctx, deviceAddress, 0x80, 6,
                       USB_DEVICE_DESCRIPTOR_TYPE << 8, 0, 18, FALSE);
    write_device_descriptor_data(ctx, deviceAddress, desc);
    write_status_packet(ctx, deviceAddress, FALSE);

    request = get_config_descriptor(hub, port, 0);
    if (request)
    {
        PUSB_CONFIGURATION_DESCRIPTOR config;
        config = (PUSB_CONFIGURATION_DESCRIPTOR)(request->Data);
        write_setup_packet(ctx, deviceAddress,
                           request->SetupPacket.bmRequest,
                           request->SetupPacket.bRequest,
                           request->SetupPacket.wValue,
                           request->SetupPacket.wIndex,
                           request->SetupPacket.wLength,
                           FALSE);

        write_data_packet(ctx, deviceAddress, request->Data,
                          request->SetupPacket.wLength, FALSE);

        write_status_packet(ctx, deviceAddress, FALSE);

        /* SET CONFIGURATION */
        write_setup_packet(ctx, deviceAddress, 0x00, 9, config->bConfigurationValue, 0, 0, TRUE);
        write_status_packet(ctx, deviceAddress, TRUE);
    }
    free(request);
}