forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuvc-streamer.h
71 lines (59 loc) · 2.09 KB
/
uvc-streamer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2015 Intel Corporation. All Rights Reserved.
#pragma once
#include "uvc-types.h"
#include "../types.h"
#include "stdio.h"
#include "stdlib.h"
#include <cstring>
#include <string>
#include <chrono>
#include <thread>
typedef void(uvc_frame_callback_t)(struct librealsense::platform::frame_object *frame, void *user_ptr);
namespace librealsense
{
namespace platform
{
struct uvc_streamer_context
{
stream_profile profile;
frame_callback user_cb;
std::shared_ptr<uvc_stream_ctrl_t> control;
rs_usb_device usb_device;
rs_usb_messenger messenger;
uint8_t request_count;
};
class uvc_streamer
{
public:
uvc_streamer(uvc_streamer_context context);
virtual ~uvc_streamer();
const uvc_streamer_context get_context() { return _context; }
bool running() { return _running; }
void start();
void stop();
void enable_user_callbacks() { _publish_frames = true; }
void disable_user_callbacks() { _publish_frames = false; }
bool wait_for_first_frame(uint32_t timeout_ms);
private:
std::mutex _running_mutex;
std::condition_variable _stopped_cv;
bool _running = false;
bool _frame_arrived = false;
bool _publish_frames = true;
int64_t _watchdog_timeout;
uvc_streamer_context _context;
dispatcher _action_dispatcher;
std::shared_ptr<watchdog> _watchdog;
uint32_t _read_buff_length;
backend_frames_queue _queue;
rs_usb_endpoint _read_endpoint;
std::vector<rs_usb_request> _requests;
std::shared_ptr<backend_frames_archive> _frames_archive;
std::shared_ptr<active_object<>> _publish_frame_thread;
std::shared_ptr<platform::usb_request_callback> _request_callback;
void init();
void flush();
};
}
}