• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
3  */
4 /*
5  * Copyright (C) 2023 Huawei Device Co., Ltd.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef AVCODECSAMPLE_MASTER_LPP_VIDEO_STREAMER_H
20 #define AVCODECSAMPLE_MASTER_LPP_VIDEO_STREAMER_H
21 
22 #include "sample_callback.h"
23 #include "dfx/error/av_codec_sample_error.h"
24 #include "av_codec_sample_log.h"
25 #include <multimedia/player_framework/lowpower_avsink_base.h>
26 #include <multimedia/player_framework/lowpower_video_sink_base.h>
27 #include <multimedia/player_framework/lowpower_audio_sink_base.h>
28 
29 class LppVideoStreamer {
30 public:
31     LppVideoStreamer() = default;
32     ~LppVideoStreamer();
33 
34     int32_t Create(const std::string &codecMime);
35 
36     int32_t Configure(const SampleInfo &sampleInfo);
37 
38     int32_t SetParameter(const SampleInfo &sampleInfo);
39     int32_t GetParameter(const SampleInfo &sampleInfo);
40 
41     int32_t SetVideoSurface(const SampleInfo &sampleInfo);
42 
43     int32_t Prepare();
44 
45     int32_t StartDecode(bool flag);
46 
47     int32_t StartRender();
48 
49     int32_t Pause();
50 
51     int32_t Resume();
52 
53     int32_t Flush();
54 
55     int32_t Stop();
56 
57     int32_t Reset();
58 
59     int32_t Destroy();
60     int32_t CallbackDestroy();
61 
62     int32_t Release();
63 
64     int32_t SetSyncAudioStreamer(OH_LowPowerAudioSink *audioStreamer);
65 
66     int32_t SetTargetStartFrame(const int64_t framePts, OH_LowPowerVideoSink_OnTargetArrived OnTargetArrived,
67         const int64_t timeoutMs, LppUserData *lppUserData);
68 
69     int32_t SetPlaybackSpeed(const float speed);
70 
71     int32_t returnFrames(LppUserData *lppUserData);
72 
73     int32_t SetCallbackCreateNull(LppUserData *lppUserData);
74     int32_t SetDataNeededListener(LppUserData *lppUserData);
75     int32_t SetStreamChangedListener(LppUserData *lppUserData);
76     int32_t SetCallback(LppUserData *lppUserData);
77     int32_t SetErrorCallback(LppUserData *lppUserData);
78     int32_t SetRenderStartCallback(LppUserData *lppUserData);
79     int32_t SetEosCallback(LppUserData *lppUserData);
80     int32_t SetFirstFrameDecodedCallback(LppUserData *lppUserData);
81 
82     int32_t RenderFirstFrame();
83 
84     bool isAVBufferMode_ = true;
85     OH_LowPowerVideoSink *lppVideoStreamer_;
86     OH_LowPowerVideoSinkCallback *lppVideoStreamerCallback_;
87 };
88 
89 #endif //AVCODECSAMPLE_MASTER_LPP_AUDIO_STREAMER_H
90