1 /*
2 * Copyright (C) 2021-2022 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 #include "media_volume.h"
17
18 #include "medialibrary_type_const.h"
19
20 using namespace std;
21
22 namespace OHOS {
23 namespace Media {
MediaVolume()24 MediaVolume::MediaVolume()
25 {
26 mediaVolumeMap_.insert(make_pair(MEDIA_TYPE_FILE, DEFAULT_MEDIAVOLUME));
27 mediaVolumeMap_.insert(make_pair(MEDIA_TYPE_IMAGE, DEFAULT_MEDIAVOLUME));
28 mediaVolumeMap_.insert(make_pair(MEDIA_TYPE_VIDEO, DEFAULT_MEDIAVOLUME));
29 mediaVolumeMap_.insert(make_pair(MEDIA_TYPE_AUDIO, DEFAULT_MEDIAVOLUME));
30 };
31 MediaVolume::~MediaVolume() = default;
32
SetSize(const int mediaType,const int64_t size)33 void MediaVolume::SetSize(const int mediaType, const int64_t size)
34 {
35 mediaVolumeMap_[mediaType] = size;
36 }
37
GetFilesSize() const38 int64_t MediaVolume::GetFilesSize() const
39 {
40 return 0; // MediaVolume does not include file size query from now on
41 }
42
GetVideosSize() const43 int64_t MediaVolume::GetVideosSize() const
44 {
45 return mediaVolumeMap_.at(MEDIA_TYPE_VIDEO);
46 }
47
GetImagesSize() const48 int64_t MediaVolume::GetImagesSize() const
49 {
50 return mediaVolumeMap_.at(MEDIA_TYPE_IMAGE);
51 }
52
GetAudiosSize() const53 int64_t MediaVolume::GetAudiosSize() const
54 {
55 return mediaVolumeMap_.at(MEDIA_TYPE_AUDIO);
56 }
57 } // namespace Media
58 } // namespace OHOS
59