video_decoder.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2014 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 API_VIDEO_CODECS_VIDEO_DECODER_H_
  11. #define API_VIDEO_CODECS_VIDEO_DECODER_H_
  12. #include <memory>
  13. #include <string>
  14. #include <vector>
  15. #include "api/video/encoded_image.h"
  16. #include "api/video/video_frame.h"
  17. #include "api/video_codecs/video_codec.h"
  18. #include "rtc_base/system/rtc_export.h"
  19. namespace webrtc {
  20. class RTC_EXPORT DecodedImageCallback {
  21. public:
  22. virtual ~DecodedImageCallback() {}
  23. virtual int32_t Decoded(VideoFrame& decodedImage) = 0;
  24. // Provides an alternative interface that allows the decoder to specify the
  25. // decode time excluding waiting time for any previous pending frame to
  26. // return. This is necessary for breaking positive feedback in the delay
  27. // estimation when the decoder has a single output buffer.
  28. virtual int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms);
  29. // TODO(sakal): Remove other implementations when upstream projects have been
  30. // updated.
  31. virtual void Decoded(VideoFrame& decodedImage,
  32. absl::optional<int32_t> decode_time_ms,
  33. absl::optional<uint8_t> qp);
  34. };
  35. class RTC_EXPORT VideoDecoder {
  36. public:
  37. virtual ~VideoDecoder() {}
  38. virtual int32_t InitDecode(const VideoCodec* codec_settings,
  39. int32_t number_of_cores) = 0;
  40. virtual int32_t Decode(const EncodedImage& input_image,
  41. bool missing_frames,
  42. int64_t render_time_ms) = 0;
  43. virtual int32_t RegisterDecodeCompleteCallback(
  44. DecodedImageCallback* callback) = 0;
  45. virtual int32_t Release() = 0;
  46. // Returns true if the decoder prefer to decode frames late.
  47. // That is, it can not decode infinite number of frames before the decoded
  48. // frame is consumed.
  49. virtual bool PrefersLateDecoding() const;
  50. virtual const char* ImplementationName() const;
  51. };
  52. } // namespace webrtc
  53. #endif // API_VIDEO_CODECS_VIDEO_DECODER_H_