• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #ifndef OHOS_AVCAST_CONTROLLER_CALLBACK_CLIENT_H
17 #define OHOS_AVCAST_CONTROLLER_CALLBACK_CLIENT_H
18 
19 #include "av_cast_controller_callback_stub.h"
20 #include "avsession_info.h"
21 
22 namespace OHOS::AVSession {
23 class AVCastControllerCallbackClient : public AVCastControllerCallbackStub {
24 public:
25     explicit AVCastControllerCallbackClient(const std::shared_ptr<AVCastControllerCallback>& callback);
26     ~AVCastControllerCallbackClient();
27 
28     ErrCode OnCastPlaybackStateChange(const AVPlaybackState& state) override;
29 
30     ErrCode OnMediaItemChange(const AVQueueItem& avQueueItem) override;
31 
32     ErrCode OnPlayNext() override;
33 
34     ErrCode OnPlayPrevious() override;
35 
36     ErrCode OnSeekDone(const int32_t seekNumber) override;
37 
38     ErrCode OnVideoSizeChange(const int32_t width, const int32_t height) override;
39 
40     ErrCode OnPlayerError(const int32_t errorCode, const std::string& errorMsg) override;
41 
42     ErrCode OnEndOfStream(const int32_t isLooping) override;
43 
44     ErrCode OnPlayRequest(const AVQueueItem& avQueueItem) override;
45 
46     ErrCode OnKeyRequest(const std::string &assetId, const std::vector<uint8_t> &keyRequestData) override;
47 
48     ErrCode OnCastValidCommandChanged(const std::vector<int32_t>& cmds) override;
49 
50     ErrCode onDataSrcRead(const std::shared_ptr<AVSharedMemoryBase>& mem, uint32_t length,
51         int64_t pos, int32_t& result) override;
52 
53     ErrCode OnCustomData(const AAFwk::WantParams& extras) override;
54 
55     void AddListenerForCastPlaybackState(const std::function<void(const AVPlaybackState&)>& listener);
56 
57 private:
58     std::function<void(const AVPlaybackState&)> castPlaybackStateListener_;
59     std::shared_ptr<AVCastControllerCallback> callback_;
60     static constexpr const char* EVENT_NAME = "AVCastControllerCallback";
61 };
62 } // namespace OHOS::AVSession
63 #endif // OHOS_AVCAST_CONTROLLER_CALLBACK_CLIENT_H
64