1/*
2 *  Copyright (c) 2012 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 WEBRTC_EXAMPLES_ANDROID_MEDIA_DEMO_JNI_MEDIA_CODEC_VIDEO_DECODER_H_
12#define WEBRTC_EXAMPLES_ANDROID_MEDIA_DEMO_JNI_MEDIA_CODEC_VIDEO_DECODER_H_
13
14#include <jni.h>
15
16#include "webrtc/examples/android/media_demo/jni/jni_helpers.h"
17#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
18
19namespace webrtc {
20
21class MediaCodecVideoDecoder : public VideoDecoder {
22 public:
23  MediaCodecVideoDecoder(JavaVM* vm, jobject decoder);
24  virtual ~MediaCodecVideoDecoder();
25
26  virtual int32_t InitDecode(const VideoCodec* codecSettings,
27                             int32_t numberOfCores);
28
29  virtual int32_t Decode(const EncodedImage& inputImage, bool missingFrames,
30                         const RTPFragmentationHeader* fragmentation,
31                         const CodecSpecificInfo* codecSpecificInfo,
32                         int64_t renderTimeMs);
33
34  virtual int32_t RegisterDecodeCompleteCallback(
35      DecodedImageCallback* callback);
36
37  virtual int32_t Release();
38
39  virtual int32_t Reset();
40
41  virtual int32_t SetCodecConfigParameters(const uint8_t* /*buffer*/,
42                                           int32_t /*size*/) {
43    return WEBRTC_VIDEO_CODEC_ERROR;
44  }
45
46  virtual VideoDecoder* Copy() {
47    CHECK(0, "Not implemented");
48    return NULL;
49  }
50
51 private:
52  JavaVM* vm_;
53  // Global reference to a (Java) MediaCodecVideoDecoder object.
54  jobject decoder_;
55  jmethodID j_start_;
56  jmethodID j_push_buffer_;
57};
58
59}  // namespace webrtc
60
61#endif  // WEBRTC_EXAMPLES_ANDROID_MEDIA_DEMO_JNI_MEDIA_CODEC_VIDEO_DECODER_H_
62