• 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_AVMEDIA_DESCRIPTION_H
17 #define OHOS_AVMEDIA_DESCRIPTION_H
18 
19 #include <bitset>
20 #include <memory>
21 #include <string>
22 #include <map>
23 
24 #include "parcel.h"
25 #include "avsession_pixel_map.h"
26 #include "want_params.h"
27 #include "av_file_descriptor.h"
28 #include "av_data_src_descriptor.h"
29 #include "av_cast_info.h"
30 
31 namespace OHOS::AVSession {
32 class AVMediaDescription : public Parcelable {
33 public:
34     enum {
35         MEDIA_DESCRIPTION_KEY_MEDIA_ID = 0,
36         MEDIA_DESCRIPTION_KEY_TITLE = 1,
37         MEDIA_DESCRIPTION_KEY_SUBTITLE = 2,
38         MEDIA_DESCRIPTION_KEY_DESCRIPTION = 3,
39         MEDIA_DESCRIPTION_KEY_ICON = 4,
40         MEDIA_DESCRIPTION_KEY_ICON_URI = 5,
41         MEDIA_DESCRIPTION_KEY_EXTRAS = 6,
42         MEDIA_DESCRIPTION_KEY_MEDIA_TYPE = 7,
43         MEDIA_DESCRIPTION_KEY_MEDIA_SIZE = 8,
44         MEDIA_DESCRIPTION_KEY_ALBUM_TITLE = 9,
45         MEDIA_DESCRIPTION_KEY_ALBUM_COVER_URI = 10,
46         MEDIA_DESCRIPTION_KEY_LYRIC_CONTENT = 11,
47         MEDIA_DESCRIPTION_KEY_LYRIC_URI = 12,
48         MEDIA_DESCRIPTION_KEY_ARTIST = 13,
49         MEDIA_DESCRIPTION_KEY_MEDIA_URI = 14,
50         MEDIA_DESCRIPTION_KEY_FD_SRC = 15,
51         MEDIA_DESCRIPTION_KEY_DURATION = 16,
52         MEDIA_DESCRIPTION_KEY_START_POSITION = 17,
53         MEDIA_DESCRIPTION_KEY_CREDITS_POSITION = 18,
54         MEDIA_DESCRIPTION_KEY_APP_NAME = 19,
55         MEDIA_DESCRIPTION_KEY_DRM_SCHEME = 20,
56         MEDIA_DESCRIPTION_KEY_DATA_SRC = 21,
57         MEDIA_DESCRIPTION_KEY_PCM_SRC = 22,
58         MEDIA_DESCRIPTION_KEY_LAUNCH_CLIENT_DATA = 23,
59         MEDIA_DESCRIPTION_KEY_MAX = 24,
60     };
61 
62     AVMediaDescription() = default;
63 
64     ~AVMediaDescription() = default;
65 
66     static AVMediaDescription* Unmarshalling(Parcel& data);
67     bool Marshalling(Parcel& parcel) const override;
68 
69     void SetMediaId(const std::string& mediaId);
70     std::string GetMediaId() const;
71 
72     void SetTitle(const std::string& title);
73     std::string GetTitle() const;
74 
75     void SetSubtitle(const std::string& subtitle);
76     std::string GetSubtitle() const;
77 
78     void SetDescription(const std::string& description);
79     std::string GetDescription() const;
80 
81     void SetIcon(const std::shared_ptr<AVSessionPixelMap>& icon);
82     std::shared_ptr<AVSessionPixelMap> GetIcon() const;
83 
84     void SetIconUri(const std::string& iconUri);
85     std::string GetIconUri() const;
86 
87     void SetExtras(const std::shared_ptr<AAFwk::WantParams>& extras);
88     std::shared_ptr<AAFwk::WantParams> GetExtras() const;
89 
90     void SetLaunchClientData(const std::string& data);
91     std::string GetLaunchClientData() const;
92 
93     void SetMediaType(const std::string& mediaType);
94     std::string GetMediaType() const;
95 
96     void SetMediaSize(const int32_t mediaSize);
97     int32_t GetMediaSize() const;
98 
99     void SetAlbumTitle(const std::string& albumTitle);
100     std::string GetAlbumTitle() const;
101 
102     void SetAlbumCoverUri(const std::string& albumCoverUri);
103     std::string GetAlbumCoverUri() const;
104 
105     void SetLyricContent(const std::string& lyricContent);
106     std::string GetLyricContent() const;
107 
108     void SetLyricUri(const std::string& lyricUri);
109     std::string GetLyricUri() const;
110 
111     void SetArtist(const std::string& artist);
112     std::string GetArtist() const;
113 
114     void SetMediaUri(const std::string& mediaUri);
115     std::string GetMediaUri() const;
116 
117     void SetFdSrc(const AVFileDescriptor& fdSrc);
118     AVFileDescriptor GetFdSrc() const;
119 
120     void SetDuration(const int32_t duration);
121     int32_t GetDuration() const;
122 
123     void SetStartPosition(const int32_t startPosition);
124     int32_t GetStartPosition() const;
125 
126     void SetCreditsPosition(const int32_t creditsPosition);
127     int32_t GetCreditsPosition() const;
128 
129     void SetAppName(const std::string& appName);
130     std::string GetAppName() const;
131 
132     void SetDrmScheme(const std::string& drmScheme);
133     std::string GetDrmScheme() const;
134 
135     void SetDataSrc(const AVDataSrcDescriptor& fdSrc);
136     AVDataSrcDescriptor GetDataSrc() const;
137 
138     void SetPcmSrc(const bool pcmSrc);
139     bool GetPcmSrc() const;
140 
141     // below not involved in Marshalling
142     void SetCastInfo(const std::shared_ptr<AVCastInfo>& castInfo);
143     std::shared_ptr<AVCastInfo> GetCastInfo() const;
144 
145     bool IsValid() const;
146 
147     void Reset();
148 
149 private:
150     std::string mediaId_ = "";
151     std::string title_ = "";
152     std::string subtitle_ = "";
153     std::string description_ = "";
154     std::shared_ptr<AVSessionPixelMap> icon_ = nullptr;
155     std::string iconUri_ = "";
156     std::shared_ptr<AAFwk::WantParams> extras_ = nullptr;
157     std::string mediaType_ = "";
158     int32_t mediaSize_ = 0;
159     std::string albumTitle_ = "";
160     std::string launchClientData_ = "";
161     std::string albumCoverUri_ = "";
162     std::string lyricContent_ = "";
163     std::string lyricUri_ = "";
164     std::string artist_ = "";
165     std::string mediaUri_ = "";
166     AVFileDescriptor fdSrc_;
167     int32_t duration_ = 0;
168     int32_t startPosition_ = 0;
169     int32_t creditsPosition_ = 0;
170     std::string appName_ = "";
171     std::string drmScheme_ = "";
172     AVDataSrcDescriptor dataSrc_;
173     bool pcmSrc_ = false;
174 
175     // below not involved in Marshalling
176     std::shared_ptr<AVCastInfo> castInfo_ = nullptr;
177 };
178 } // namespace OHOS::AVSession
179 #endif // OHOS_AVMEDIA_DESCRIPTION_H
180 
181