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