1 /* 2 * Copyright (C) 2024 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 TRANSCODER_SERVICE_CLIENT_H 17 #define TRANSCODER_SERVICE_CLIENT_H 18 19 #include <thread> 20 #include "i_transcoder_service.h" 21 #include "i_standard_transcoder_service.h" 22 #include "transcoder_listener_stub.h" 23 #include "monitor_client_object.h" 24 25 namespace OHOS { 26 namespace Media { 27 class TransCoderClient : public ITransCoderService, public MonitorClientObject { 28 public: 29 static std::shared_ptr<TransCoderClient> Create(const sptr<IStandardTransCoderService> &ipcProxy); 30 explicit TransCoderClient(const sptr<IStandardTransCoderService> &ipcProxy); 31 ~TransCoderClient(); 32 // ITransCoderService override 33 int32_t SetVideoEncoder(VideoCodecFormat encoder) override; 34 int32_t SetVideoSize(int32_t width, int32_t height) override; 35 int32_t SetVideoEncodingBitRate(int32_t rate) override; 36 int32_t SetAudioEncoder(AudioCodecFormat encoder) override; 37 int32_t SetAudioEncodingBitRate(int32_t bitRate) override; 38 int32_t SetOutputFormat(OutputFormatType format) override; 39 int32_t SetInputFile(int32_t fd, int64_t offset, int64_t size) override; 40 int32_t SetOutputFile(int32_t fd) override; 41 int32_t SetTransCoderCallback(const std::shared_ptr<TransCoderCallback> &callback) override; 42 int32_t Prepare() override; 43 int32_t Start() override; 44 int32_t Pause() override; 45 int32_t Resume() override; 46 int32_t Cancel() override; 47 int32_t Release() override; 48 // TransCoderClient 49 void MediaServerDied(); 50 51 private: 52 int32_t CreateListenerObject(); 53 int32_t ExecuteWhen(int32_t ret, bool ok); 54 55 sptr<IStandardTransCoderService> transCoderProxy_ = nullptr; 56 sptr<TransCoderListenerStub> listenerStub_ = nullptr; 57 std::shared_ptr<TransCoderCallback> callback_ = nullptr; 58 std::mutex mutex_; 59 }; 60 } // namespace Media 61 } // namespace OHOS 62 #endif // TRANSCODER_SERVICE_CLIENT_H 63