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_DRM_SCHEME = 20, 54 MEDIA_DESCRIPTION_KEY_MAX = 21, 55 }; 56 57 AVMediaDescription() = default; 58 59 ~AVMediaDescription() = default; 60 61 static AVMediaDescription* Unmarshalling(Parcel& data); 62 bool Marshalling(Parcel& parcel) const override; 63 64 void SetMediaId(const std::string& mediaId); 65 std::string GetMediaId() const; 66 67 void SetTitle(const std::string& title); 68 std::string GetTitle() const; 69 70 void SetSubtitle(const std::string& subtitle); 71 std::string GetSubtitle() const; 72 73 void SetDescription(const std::string& description); 74 std::string GetDescription() const; 75 76 void SetIcon(const std::shared_ptr<AVSessionPixelMap>& icon); 77 std::shared_ptr<AVSessionPixelMap> GetIcon() const; 78 79 void SetIconUri(const std::string& iconUri); 80 std::string GetIconUri() const; 81 82 void SetExtras(const std::shared_ptr<AAFwk::WantParams>& extras); 83 std::shared_ptr<AAFwk::WantParams> GetExtras() const; 84 85 void SetMediaType(const std::string& mediaType); 86 std::string GetMediaType() const; 87 88 void SetMediaSize(const int32_t mediaSize); 89 int32_t GetMediaSize() const; 90 91 void SetAlbumTitle(const std::string& albumTitle); 92 std::string GetAlbumTitle() const; 93 94 void SetAlbumCoverUri(const std::string& albumCoverUri); 95 std::string GetAlbumCoverUri() const; 96 97 void SetLyricContent(const std::string& lyricContent); 98 std::string GetLyricContent() const; 99 100 void SetLyricUri(const std::string& lyricUri); 101 std::string GetLyricUri() const; 102 103 void SetArtist(const std::string& artist); 104 std::string GetArtist() const; 105 106 void SetMediaUri(const std::string& mediaUri); 107 std::string GetMediaUri() const; 108 109 void SetFdSrc(const AVFileDescriptor& fdSrc); 110 AVFileDescriptor GetFdSrc() const; 111 112 void SetDuration(const int32_t duration); 113 int32_t GetDuration() const; 114 115 void SetStartPosition(const int32_t startPosition); 116 int32_t GetStartPosition() const; 117 118 void SetCreditsPosition(const int32_t creditsPosition); 119 int32_t GetCreditsPosition() const; 120 121 void SetAppName(const std::string& appName); 122 std::string GetAppName() const; 123 124 void SetDrmScheme(const std::string& drmScheme); 125 std::string GetDrmScheme() const; 126 127 bool IsValid() const; 128 129 void Reset(); 130 131 private: 132 std::string mediaId_ = ""; 133 std::string title_ = ""; 134 std::string subtitle_ = ""; 135 std::string description_ = ""; 136 std::shared_ptr<AVSessionPixelMap> icon_ = nullptr; 137 std::string iconUri_ = ""; 138 std::shared_ptr<AAFwk::WantParams> extras_ = nullptr; 139 std::string mediaType_ = ""; 140 int32_t mediaSize_ = 0; 141 std::string albumTitle_ = ""; 142 std::string albumCoverUri_ = ""; 143 std::string lyricContent_ = ""; 144 std::string lyricUri_ = ""; 145 std::string artist_ = ""; 146 std::string mediaUri_ = ""; 147 AVFileDescriptor fdSrc_; 148 int32_t duration_ = 0; 149 int32_t startPosition_ = 0; 150 int32_t creditsPosition_ = 0; 151 std::string appName_ = ""; 152 std::string drmScheme_ = ""; 153 }; 154 } // namespace OHOS::AVSession 155 #endif // OHOS_AVMEDIA_DESCRIPTION_H 156 157