jetson_video_decoder.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2015 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. */
  11. #ifndef SORA_HWENC_JETSON_JETSON_VIDEO_DECODER_H_
  12. #define SORA_HWENC_JETSON_JETSON_VIDEO_DECODER_H_
  13. // WebRTC
  14. #include <api/video_codecs/video_decoder.h>
  15. #include <common_video/include/video_frame_buffer_pool.h>
  16. #include <rtc_base/platform_thread.h>
  17. struct v4l2_crop;
  18. class NvV4l2Element;
  19. class NvVideoDecoder;
  20. namespace sora {
  21. class JetsonVideoDecoder : public webrtc::VideoDecoder {
  22. public:
  23. JetsonVideoDecoder(webrtc::VideoCodecType codec);
  24. ~JetsonVideoDecoder() override;
  25. static bool IsSupported(webrtc::VideoCodecType codec);
  26. bool Configure(const Settings& settings) override;
  27. int32_t Decode(const webrtc::EncodedImage& input_image,
  28. bool missing_frames,
  29. int64_t render_time_ms) override;
  30. int32_t RegisterDecodeCompleteCallback(
  31. webrtc::DecodedImageCallback* callback) override;
  32. int32_t Release() override;
  33. const char* ImplementationName() const override;
  34. private:
  35. int32_t JetsonConfigure();
  36. bool JetsonRelease();
  37. void SendEOS(NvV4l2Element* element);
  38. static void CaptureLoopFunction(void* obj);
  39. void CaptureLoop();
  40. int32_t SetCapture();
  41. uint32_t input_format_;
  42. NvVideoDecoder* decoder_;
  43. webrtc::DecodedImageCallback* decode_complete_callback_;
  44. webrtc::VideoFrameBufferPool buffer_pool_;
  45. rtc::PlatformThread capture_loop_;
  46. std::atomic<bool> eos_;
  47. std::atomic<bool> got_error_;
  48. int dst_dma_fd_;
  49. std::shared_ptr<v4l2_crop> capture_crop_;
  50. };
  51. } // namespace sora
  52. #endif