video_receiver2.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_
  11. #define MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_
  12. #include "modules/video_coding/decoder_database.h"
  13. #include "modules/video_coding/encoded_frame.h"
  14. #include "modules/video_coding/generic_decoder.h"
  15. #include "modules/video_coding/timing.h"
  16. #include "rtc_base/thread_checker.h"
  17. #include "system_wrappers/include/clock.h"
  18. namespace webrtc {
  19. // This class is a copy of vcm::VideoReceiver, trimmed down to what's used by
  20. // VideoReceive stream, with the aim to incrementally trim it down further and
  21. // ultimately delete it. It's difficult to do this incrementally with the
  22. // original VideoReceiver class, since it is used by the legacy
  23. // VideoCodingModule api.
  24. class VideoReceiver2 {
  25. public:
  26. VideoReceiver2(Clock* clock, VCMTiming* timing);
  27. ~VideoReceiver2();
  28. int32_t RegisterReceiveCodec(uint8_t payload_type,
  29. const VideoCodec* receiveCodec,
  30. int32_t numberOfCores);
  31. void RegisterExternalDecoder(VideoDecoder* externalDecoder,
  32. uint8_t payloadType);
  33. int32_t RegisterReceiveCallback(VCMReceiveCallback* receiveCallback);
  34. int32_t Decode(const webrtc::VCMEncodedFrame* frame);
  35. // Notification methods that are used to check our internal state and validate
  36. // threading assumptions. These are called by VideoReceiveStream.
  37. // See |IsDecoderThreadRunning()| for more details.
  38. void DecoderThreadStarting();
  39. void DecoderThreadStopped();
  40. private:
  41. // Used for DCHECKing thread correctness.
  42. // In build where DCHECKs are enabled, will return false before
  43. // DecoderThreadStarting is called, then true until DecoderThreadStopped
  44. // is called.
  45. // In builds where DCHECKs aren't enabled, it will return true.
  46. bool IsDecoderThreadRunning();
  47. rtc::ThreadChecker construction_thread_checker_;
  48. rtc::ThreadChecker decoder_thread_checker_;
  49. Clock* const clock_;
  50. VCMTiming* timing_;
  51. VCMDecodedFrameCallback decodedFrameCallback_;
  52. // Callbacks are set before the decoder thread starts.
  53. // Once the decoder thread has been started, usage of |_codecDataBase| moves
  54. // over to the decoder thread.
  55. VCMDecoderDataBase codecDataBase_;
  56. #if RTC_DCHECK_IS_ON
  57. bool decoder_thread_is_running_ = false;
  58. #endif
  59. };
  60. } // namespace webrtc
  61. #endif // MODULES_VIDEO_CODING_VIDEO_RECEIVER2_H_