• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_MEDIA_TRANSCODING_REQUEST_H
18 #define ANDROID_MEDIA_TRANSCODING_REQUEST_H
19 
20 #include <aidl/android/media/TranscodingRequestParcel.h>
21 #include <android/binder_parcel.h>
22 
23 namespace android {
24 
25 using ::aidl::android::media::TranscodingRequestParcel;
26 
27 // Helper class for duplicating a TranscodingRequestParcel
28 class TranscodingRequest : public TranscodingRequestParcel {
29 public:
30     TranscodingRequest() = default;
TranscodingRequest(const TranscodingRequestParcel & parcel)31     TranscodingRequest(const TranscodingRequestParcel& parcel) { setTo(parcel); }
TranscodingRequest(const TranscodingRequest & request)32     TranscodingRequest(const TranscodingRequest& request) { setTo(request); }
33     TranscodingRequest& operator=(const TranscodingRequest& request) {
34         setTo(request);
35         return *this;
36     }
37 
38 private:
setTo(const TranscodingRequestParcel & parcel)39     void setTo(const TranscodingRequestParcel& parcel) {
40         if (__builtin_available(android __TRANSCODING_MIN_API__, *)) {
41             AParcel* p = AParcel_create();
42             parcel.writeToParcel(p);
43             AParcel_setDataPosition(p, 0);
44             readFromParcel(p);
45             AParcel_delete(p);
46         } else {
47             sourceFilePath = parcel.sourceFilePath;
48             sourceFd = ndk::ScopedFileDescriptor(dup(parcel.sourceFd.get()));
49             destinationFilePath = parcel.destinationFilePath;
50             destinationFd = ndk::ScopedFileDescriptor(dup(parcel.destinationFd.get()));
51             clientUid = parcel.clientUid;
52             clientPid = parcel.clientPid;
53             clientPackageName = parcel.clientPackageName;
54             transcodingType = parcel.transcodingType;
55             requestedVideoTrackFormat = parcel.requestedVideoTrackFormat;
56             priority = parcel.priority;
57             requestProgressUpdate = parcel.requestProgressUpdate;
58             requestSessionEventUpdate = parcel.requestSessionEventUpdate;
59             isForTesting = parcel.isForTesting;
60             testConfig = parcel.testConfig;
61         }
62     }
63 };
64 
65 }  // namespace android
66 #endif  // ANDROID_MEDIA_TRANSCODING_REQUEST_H
67