• 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 
29 namespace OHOS::AVSession {
30 class AVMediaDescription : public Parcelable {
31 public:
32     enum {
33         MEDIA_DESCRIPTION_KEY_MEDIA_ID = 0,
34         MEDIA_DESCRIPTION_KEY_TITLE = 1,
35         MEDIA_DESCRIPTION_KEY_SUBTITLE = 2,
36         MEDIA_DESCRIPTION_KEY_DESCRIPTION = 3,
37         MEDIA_DESCRIPTION_KEY_ICON = 4,
38         MEDIA_DESCRIPTION_KEY_ICON_URI = 5,
39         MEDIA_DESCRIPTION_KEY_EXTRAS = 6,
40         MEDIA_DESCRIPTION_KEY_MEDIA_TYPE = 7,
41         MEDIA_DESCRIPTION_KEY_MEDIA_SIZE = 8,
42         MEDIA_DESCRIPTION_KEY_ALBUM_TITLE = 9,
43         MEDIA_DESCRIPTION_KEY_ALBUM_COVER_URI = 10,
44         MEDIA_DESCRIPTION_KEY_LYRIC_CONTENT = 11,
45         MEDIA_DESCRIPTION_KEY_LYRIC_URI = 12,
46         MEDIA_DESCRIPTION_KEY_ARTIST = 13,
47         MEDIA_DESCRIPTION_KEY_MEDIA_URI = 14,
48         MEDIA_DESCRIPTION_KEY_FD_SRC = 15,
49         MEDIA_DESCRIPTION_KEY_DURATION = 16,
50         MEDIA_DESCRIPTION_KEY_START_POSITION = 17,
51         MEDIA_DESCRIPTION_KEY_CREDITS_POSITION = 18,
52         MEDIA_DESCRIPTION_KEY_APP_NAME = 19,
53         MEDIA_DESCRIPTION_KEY_MAX = 20,
54     };
55 
56     AVMediaDescription() = default;
57 
58     ~AVMediaDescription() = default;
59 
60     static AVMediaDescription* Unmarshalling(Parcel& data);
61     bool Marshalling(Parcel& parcel) const override;
62 
63     void SetMediaId(const std::string& mediaId);
64     std::string GetMediaId() const;
65 
66     void SetTitle(const std::string& title);
67     std::string GetTitle() const;
68 
69     void SetSubtitle(const std::string& subtitle);
70     std::string GetSubtitle() const;
71 
72     void SetDescription(const std::string& description);
73     std::string GetDescription() const;
74 
75     void SetIcon(const std::shared_ptr<AVSessionPixelMap>& icon);
76     std::shared_ptr<AVSessionPixelMap> GetIcon() const;
77 
78     void SetIconUri(const std::string& iconUri);
79     std::string GetIconUri() const;
80 
81     void SetExtras(const std::shared_ptr<AAFwk::WantParams>& extras);
82     std::shared_ptr<AAFwk::WantParams> GetExtras() const;
83 
84     void SetMediaType(const std::string& mediaType);
85     std::string GetMediaType() const;
86 
87     void SetMediaSize(const int32_t mediaSize);
88     int32_t GetMediaSize() const;
89 
90     void SetAlbumTitle(const std::string& albumTitle);
91     std::string GetAlbumTitle() const;
92 
93     void SetAlbumCoverUri(const std::string& albumCoverUri);
94     std::string GetAlbumCoverUri() const;
95 
96     void SetLyricContent(const std::string& lyricContent);
97     std::string GetLyricContent() const;
98 
99     void SetLyricUri(const std::string& lyricUri);
100     std::string GetLyricUri() const;
101 
102     void SetArtist(const std::string& artist);
103     std::string GetArtist() const;
104 
105     void SetMediaUri(const std::string& mediaUri);
106     std::string GetMediaUri() const;
107 
108     void SetFdSrc(const AVFileDescriptor& fdSrc);
109     AVFileDescriptor GetFdSrc() const;
110 
111     void SetDuration(const int32_t duration);
112     int32_t GetDuration() const;
113 
114     void SetStartPosition(const int32_t startPosition);
115     int32_t GetStartPosition() const;
116 
117     void SetCreditsPosition(const int32_t creditsPosition);
118     int32_t GetCreditsPosition() const;
119 
120     void SetAppName(const std::string& appName);
121     std::string GetAppName() const;
122 
123     bool IsValid() const;
124 
125     void Reset();
126 
127 private:
128     std::string mediaId_ = "";
129     std::string title_ = "";
130     std::string subtitle_ = "";
131     std::string description_ = "";
132     std::shared_ptr<AVSessionPixelMap> icon_ = nullptr;
133     std::string iconUri_ = "";
134     std::shared_ptr<AAFwk::WantParams> extras_ = nullptr;
135     std::string mediaType_ = "";
136     int32_t mediaSize_ = 0;
137     std::string albumTitle_ = "";
138     std::string albumCoverUri_ = "";
139     std::string lyricContent_ = "";
140     std::string lyricUri_ = "";
141     std::string artist_ = "";
142     std::string mediaUri_ = "";
143     AVFileDescriptor fdSrc_;
144     int32_t duration_ = 0;
145     int32_t startPosition_ = 0;
146     int32_t creditsPosition_ = 0;
147     std::string appName_ = "";
148 };
149 } // namespace OHOS::AVSession
150 #endif // OHOS_AVMEDIA_DESCRIPTION_H
151 
152