1 /* 2 * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 "common.h" 17 18 namespace OHOS { 19 namespace Sharing { 20 21 #define VIDEO_RESOLUTION_640 640 22 #define VIDEO_RESOLUTION_480 480 23 #define VIDEO_RESOLUTION_1280 1280 24 #define VIDEO_RESOLUTION_720 720 25 #define VIDEO_RESOLUTION_1920 1920 26 #define VIDEO_RESOLUTION_1080 1080 27 28 #define VIDEO_FRAME_RATE_60 60 29 #define VIDEO_FRAME_RATE_25 25 30 #define VIDEO_FRAME_RATE_30 30 31 32 #define AUDIO_SAMPLE_BIT 16 33 #define AUDIO_SAMEPLE_CHANNEL 2 34 SetVideoTrack(VideoTrack & videoTrack,VideoFormat videoFormat)35void Common::SetVideoTrack(VideoTrack &videoTrack, VideoFormat videoFormat) 36 { 37 switch (videoFormat) { 38 case VideoFormat::VIDEO_640X480_60: 39 videoTrack.codecId = CodecId::CODEC_H264; 40 videoTrack.width = VIDEO_RESOLUTION_640; 41 videoTrack.height = VIDEO_RESOLUTION_480; 42 videoTrack.frameRate = VIDEO_FRAME_RATE_60; 43 break; 44 case VideoFormat::VIDEO_1280X720_25: 45 videoTrack.codecId = CodecId::CODEC_H264; 46 videoTrack.width = VIDEO_RESOLUTION_1280; 47 videoTrack.height = VIDEO_RESOLUTION_720; 48 videoTrack.frameRate = VIDEO_FRAME_RATE_25; 49 break; 50 case VideoFormat::VIDEO_1280X720_30: 51 videoTrack.codecId = CodecId::CODEC_H264; 52 videoTrack.width = VIDEO_RESOLUTION_1280; 53 videoTrack.height = VIDEO_RESOLUTION_720; 54 videoTrack.frameRate = VIDEO_FRAME_RATE_30; 55 break; 56 case VideoFormat::VIDEO_1920X1080_25: 57 videoTrack.codecId = CodecId::CODEC_H264; 58 videoTrack.width = VIDEO_RESOLUTION_1920; 59 videoTrack.height = VIDEO_RESOLUTION_1080; 60 videoTrack.frameRate = VIDEO_FRAME_RATE_25; 61 break; 62 case VideoFormat::VIDEO_1920X1080_30: 63 videoTrack.codecId = CodecId::CODEC_H264; 64 videoTrack.width = VIDEO_RESOLUTION_1920; 65 videoTrack.height = VIDEO_RESOLUTION_1080; 66 videoTrack.frameRate = VIDEO_FRAME_RATE_30; 67 break; 68 default: 69 SHARING_LOGI("none process case."); 70 break; 71 } 72 } 73 SetAudioTrack(AudioTrack & audioTrack,AudioFormat audioFormat)74void Common::SetAudioTrack(AudioTrack &audioTrack, AudioFormat audioFormat) 75 { 76 switch (audioFormat) { 77 case AudioFormat::AUDIO_44100_8_2: 78 case AudioFormat::AUDIO_44100_16_2: 79 audioTrack.codecId = CodecId::CODEC_AAC; 80 audioTrack.sampleRate = AUDIO_SAMPLE_RATE_44100; 81 audioTrack.sampleBit = AUDIO_SAMPLE_BIT; 82 audioTrack.channels = AUDIO_SAMEPLE_CHANNEL; 83 break; 84 case AudioFormat::AUDIO_48000_16_2: 85 audioTrack.codecId = CodecId::CODEC_AAC; 86 audioTrack.sampleRate = AUDIO_SAMPLE_RATE_48000; 87 audioTrack.sampleBit = AUDIO_SAMPLE_BIT; 88 audioTrack.channels = AUDIO_SAMEPLE_CHANNEL; 89 break; 90 default: 91 SHARING_LOGI("none process case."); 92 break; 93 } 94 } 95 } // namespace Sharing 96 } // namespace OHOS