Twitch SDK (Internal)
passthroughvideocapture.h
Go to the documentation of this file.
1 /********************************************************************************************
2 * Twitch Broadcasting SDK
3 *
4 * This software is supplied under the terms of a license agreement with Twitch Interactive, Inc. and
5 * may not be copied or used except in accordance with the terms of that agreement
6 * Copyright (c) 2012-2016 Twitch Interactive, Inc.
7 *********************************************************************************************/
8 
9 #pragma once
10 
12 
14 
15 #include <vector>
16 #include <mutex>
17 #include <condition_variable>
18 
19 
20 namespace ttv
21 {
22  class IThread;
23 
24  namespace broadcast
25  {
26  class PassThroughVideoCapture;
27  class IPreEncodedVideoFrameReceiver;
28  }
29 }
30 
32 {
33 public:
35  virtual ~PassThroughVideoCapture();
36 
37  TTV_ErrorCode EnqueueVideoPacket(std::vector<uint8_t>&& videoPacket, bool keyframe, uint64_t timestamp);
38 
39 public:
40  // IVideoCapture Implementation
41  virtual std::string GetName() const override;
42  virtual TTV_ErrorCode SetVideoEncoder(const std::shared_ptr<IVideoEncoder>& encoder) override;
43  virtual TTV_ErrorCode SetFrameQueue(const std::shared_ptr<IVideoFrameQueue>& queue) override;
44  virtual TTV_ErrorCode Initialize() override;
45  virtual TTV_ErrorCode Start(const VideoParams& videoParams) override;
46  virtual TTV_ErrorCode Stop() override;
47  virtual TTV_ErrorCode Shutdown() override;
48 
49 private:
50  struct QueueEntry
51  {
52  std::vector<uint8_t> packet;
53  uint64_t timestamp;
54  bool keyframe;
55  };
56 
57  std::shared_ptr<IVideoEncoder> mVideoEncoder;
58  std::shared_ptr<IVideoFrameQueue> mFrameQueue;
59  std::shared_ptr<IPreEncodedVideoFrameReceiver> mReceiver;
60  std::shared_ptr<IThread> mThread;
62 
64 
65  std::mutex mMutex;
66  std::condition_variable mCondition;
67 
69  bool mStarted;
70 };
std::condition_variable mCondition
Definition: passthroughvideocapture.h:66
Definition: passthroughvideocapture.h:50
bool keyframe
Definition: passthroughvideocapture.h:54
virtual TTV_ErrorCode Stop() override
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
Definition: passthroughvideocapture.h:31
bool mStarted
Definition: passthroughvideocapture.h:69
Definition: ivideocapture.h:38
std::vector< uint8_t > packet
Definition: passthroughvideocapture.h:52
virtual TTV_ErrorCode Initialize() override
std::shared_ptr< IVideoEncoder > mVideoEncoder
Definition: passthroughvideocapture.h:57
Definition: broadcasttypes.h:80
std::shared_ptr< IVideoFrameQueue > mFrameQueue
Definition: passthroughvideocapture.h:58
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
std::mutex mMutex
Definition: passthroughvideocapture.h:65
TTV_ErrorCode EnqueueVideoPacket(std::vector< uint8_t > &&videoPacket, bool keyframe, uint64_t timestamp)
uint64_t timestamp
Definition: passthroughvideocapture.h:53
virtual TTV_ErrorCode Start(const VideoParams &videoParams) override
virtual TTV_ErrorCode SetFrameQueue(const std::shared_ptr< IVideoFrameQueue > &queue) override
std::shared_ptr< IPreEncodedVideoFrameReceiver > mReceiver
Definition: passthroughvideocapture.h:59
Definition: concurrentqueue.h:16
virtual TTV_ErrorCode Shutdown() override
ConcurrentQueue< std::shared_ptr< QueueEntry > > mVideoPacketQueue
Definition: passthroughvideocapture.h:63
virtual TTV_ErrorCode SetVideoEncoder(const std::shared_ptr< IVideoEncoder > &encoder) override
virtual std::string GetName() const override
std::shared_ptr< IThread > mThread
Definition: passthroughvideocapture.h:60
VideoParams mVideoParams
Definition: passthroughvideocapture.h:61
bool mInitialized
Definition: passthroughvideocapture.h:68