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