• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "image_decoder_callback.h"
17 
18 #include "dscreen_log.h"
19 #include "image_sink_decoder.h"
20 
21 namespace OHOS {
22 namespace DistributedHardware {
OnError(Media::AVCodecErrorType errorType,int32_t errorCode)23 void ImageDecoderCallback::OnError(Media::AVCodecErrorType errorType, int32_t errorCode)
24 {
25     DHLOGD("%s: OnError.", LOG_TAG);
26     std::shared_ptr<ImageSinkDecoder> decoder = videoDecoder_.lock();
27     if (decoder == nullptr) {
28         DHLOGE("decoder is nullptr.");
29         return;
30     }
31     decoder->OnError(errorType, errorCode);
32 }
33 
OnOutputBufferAvailable(uint32_t index,Media::AVCodecBufferInfo info,Media::AVCodecBufferFlag flag)34 void ImageDecoderCallback::OnOutputBufferAvailable(uint32_t index, Media::AVCodecBufferInfo info,
35     Media::AVCodecBufferFlag flag)
36 {
37     DHLOGD("%s: OnOutputBufferAvailable.", LOG_TAG);
38     std::shared_ptr<ImageSinkDecoder> decoder = videoDecoder_.lock();
39     if (decoder == nullptr) {
40         DHLOGE("decoder is nullptr.");
41         return;
42     }
43     decoder->OnOutputBufferAvailable(index, info, flag);
44 }
45 
OnInputBufferAvailable(uint32_t index)46 void ImageDecoderCallback::OnInputBufferAvailable(uint32_t index)
47 {
48     DHLOGD("%s: OnInputBufferAvailable.", LOG_TAG);
49     std::shared_ptr<ImageSinkDecoder> decoder = videoDecoder_.lock();
50     if (decoder == nullptr) {
51         DHLOGE("decoder is nullptr.");
52         return;
53     }
54     decoder->OnInputBufferAvailable(index);
55 }
56 
OnOutputFormatChanged(const Media::Format & format)57 void ImageDecoderCallback::OnOutputFormatChanged(const Media::Format &format)
58 {
59     DHLOGD("%s: OnOutputFormatChanged.", LOG_TAG);
60     std::shared_ptr<ImageSinkDecoder> decoder = videoDecoder_.lock();
61     if (decoder == nullptr) {
62         DHLOGE("decoder is nullptr.");
63         return;
64     }
65     decoder->OnOutputFormatChanged(format);
66 }
67 } // namespace DistributedHardware
68 } // namespace OHOS