|
42 | 42 | class ImageProvider |
43 | 43 | { |
44 | 44 | public: |
45 | | - ImageProvider(const unsigned int w, const unsigned int h, const unsigned int numFrames, const VdoFormat format); |
46 | | - ~ImageProvider(); |
47 | | - bool InitImageProvider(); |
48 | 45 | static bool ChooseStreamResolution( |
49 | | - const unsigned int reqWidth, |
50 | | - const unsigned int reqHeight, |
51 | | - unsigned int &chosenWidth, |
52 | | - unsigned int &chosenHeight); |
53 | | - static bool CreateStream(ImageProvider &provider); |
54 | | - static bool AllocateVdoBuffers(ImageProvider &provider, VdoStream &vdoStream); |
55 | | - static void ReleaseVdoBuffers(ImageProvider &provider); |
56 | | - static VdoBuffer *GetLastFrameBlocking(ImageProvider &provider); |
57 | | - static void ReturnFrame(ImageProvider &provider, VdoBuffer &buffer); |
58 | | - static void *threadEntry(void *data); |
| 46 | + const unsigned int req_width, |
| 47 | + const unsigned int req_height, |
| 48 | + unsigned int &chosen_width, |
| 49 | + unsigned int &chosen_height); |
59 | 50 | static bool StartFrameFetch(ImageProvider &provider); |
60 | 51 | static bool StopFrameFetch(ImageProvider &provider); |
| 52 | + static void *threadEntry(void *data); |
| 53 | + |
| 54 | + ImageProvider( |
| 55 | + const unsigned int width, |
| 56 | + const unsigned int height, |
| 57 | + const unsigned int num_frames, |
| 58 | + const VdoFormat format); |
| 59 | + ~ImageProvider(); |
| 60 | + VdoBuffer *GetLastFrameBlocking(); |
| 61 | + void ReturnFrame(VdoBuffer &buffer); |
| 62 | + |
| 63 | + private: |
| 64 | + bool AllocateVdoBuffers(); |
| 65 | + void ReleaseVdoBuffers(); |
| 66 | + void RunLoopIteration(); |
61 | 67 |
|
62 | | - // Keeping track of frames' statuses. |
63 | 68 | GQueue *delivered_frames_; |
64 | 69 | GQueue *processed_frames_; |
65 | | - |
66 | | - // To support fetching frames asynchonously with VDO. |
67 | | - pthread_mutex_t frame_mutex_; |
68 | 70 | pthread_cond_t frame_deliver_cond_; |
| 71 | + pthread_mutex_t frame_mutex_; |
69 | 72 | pthread_t fetcher_thread_; |
70 | 73 | std::atomic_bool shutdown_; |
71 | | - |
72 | | - private: |
73 | | - void RunLoopIteration(); |
74 | | - bool initialized_; |
75 | | - unsigned int width_; |
76 | | - unsigned int height_; |
77 | | - // Number of frames to keep in the delivered_frames queue. |
78 | | - unsigned int num_app_frames_; |
79 | | - // Stream configuration parameters. |
80 | | - VdoFormat vdo_format_; |
81 | | - // Vdo stream and buffers handling. |
82 | | - VdoStream *vdo_stream_; |
| 74 | + unsigned int num_frames_; |
83 | 75 | VdoBuffer *vdo_buffers_[NUM_VDO_BUFFERS]; |
| 76 | + VdoStream *vdo_stream_; |
84 | 77 | }; |
0 commit comments