Changeset 96134 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 11, 2022 2:07:03 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xml/Settings.cpp
r95920 r96134 2838 2838 } 2839 2839 strFeatures.strip(); 2840 } 2841 2842 /** 2843 * Returns a recording settings audio codec from a given string. 2844 * 2845 * @returns VBox status code. 2846 * @retval VERR_NOT_SUPPORTED if audio codec is invalid or not supported. 2847 * @param strCodec String that contains the codec name. 2848 * @param enmCodec Where to return the audio codec on success. 2849 * 2850 * @note An empty string will return "none" (no codec). 2851 */ 2852 /* static */ 2853 int RecordingScreenSettings::audioCodecFromString(const com::Utf8Str &strCodec, RecordingAudioCodec_T &enmCodec) 2854 { 2855 if ( RTStrIStr(strCodec.c_str(), "none") 2856 || strCodec.isEmpty()) 2857 { 2858 enmCodec = RecordingAudioCodec_None; 2859 return VINF_SUCCESS; 2860 } 2861 else if (RTStrIStr(strCodec.c_str(), "wav")) 2862 { 2863 enmCodec = RecordingAudioCodec_WavPCM; 2864 return VINF_SUCCESS; 2865 } 2866 else if (RTStrIStr(strCodec.c_str(), "mp3")) 2867 { 2868 enmCodec = RecordingAudioCodec_MP3; 2869 return VINF_SUCCESS; 2870 } 2871 else if (RTStrIStr(strCodec.c_str(), "opus")) 2872 { 2873 enmCodec = RecordingAudioCodec_Opus; 2874 return VINF_SUCCESS; 2875 } 2876 else if (RTStrIStr(strCodec.c_str(), "vorbis")) 2877 { 2878 enmCodec = RecordingAudioCodec_OggVorbis; 2879 return VINF_SUCCESS; 2880 } 2881 2882 AssertFailedReturn(VERR_NOT_SUPPORTED); 2883 } 2884 2885 /** 2886 * Converts an audio codec to a serializable string. 2887 * 2888 * @param enmCodec Codec to convert to a string. 2889 * @param strCodec Where to return the audio codec converted as a string. 2890 */ 2891 /* static */ 2892 void RecordingScreenSettings::audioCodecToString(const RecordingAudioCodec_T &enmCodec, com::Utf8Str &strCodec) 2893 { 2894 switch (enmCodec) 2895 { 2896 case RecordingAudioCodec_None: strCodec = "none"; return; 2897 case RecordingAudioCodec_WavPCM: strCodec = "wav"; return; 2898 case RecordingAudioCodec_MP3: strCodec = "mp3"; return; 2899 case RecordingAudioCodec_Opus: strCodec = "opus"; return; 2900 case RecordingAudioCodec_OggVorbis: strCodec = "vorbis"; return; 2901 default: AssertFailedReturnVoid(); 2902 } 2903 } 2904 2905 /** 2906 * Returns a recording settings video codec from a given string. 2907 * 2908 * @returns VBox status code. 2909 * @retval VERR_NOT_SUPPORTED if video codec is invalid or not supported. 2910 * @param strCodec String that contains the codec name. 2911 * @param enmCodec Where to return the video codec on success. 2912 * 2913 * @note An empty string will return "none" (no codec). 2914 */ 2915 /* static */ 2916 int RecordingScreenSettings::videoCodecFromString(const com::Utf8Str &strCodec, RecordingVideoCodec_T &enmCodec) 2917 { 2918 if ( RTStrIStr(strCodec.c_str(), "none") 2919 || strCodec.isEmpty()) 2920 { 2921 enmCodec = RecordingVideoCodec_None; 2922 return VINF_SUCCESS; 2923 } 2924 else if (RTStrIStr(strCodec.c_str(), "MJPEG")) 2925 { 2926 enmCodec = RecordingVideoCodec_MJPEG; 2927 return VINF_SUCCESS; 2928 } 2929 else if (RTStrIStr(strCodec.c_str(), "H262")) 2930 { 2931 enmCodec = RecordingVideoCodec_H262; 2932 return VINF_SUCCESS; 2933 } 2934 else if (RTStrIStr(strCodec.c_str(), "H264")) 2935 { 2936 enmCodec = RecordingVideoCodec_H264; 2937 return VINF_SUCCESS; 2938 } 2939 else if (RTStrIStr(strCodec.c_str(), "H265")) 2940 { 2941 enmCodec = RecordingVideoCodec_H265; 2942 return VINF_SUCCESS; 2943 } 2944 else if (RTStrIStr(strCodec.c_str(), "H266")) 2945 { 2946 enmCodec = RecordingVideoCodec_H266; 2947 return VINF_SUCCESS; 2948 } 2949 else if (RTStrIStr(strCodec.c_str(), "VP8")) 2950 { 2951 enmCodec = RecordingVideoCodec_VP8; 2952 return VINF_SUCCESS; 2953 } 2954 else if (RTStrIStr(strCodec.c_str(), "VP9")) 2955 { 2956 enmCodec = RecordingVideoCodec_VP9; 2957 return VINF_SUCCESS; 2958 } 2959 else if (RTStrIStr(strCodec.c_str(), "AV1")) 2960 { 2961 enmCodec = RecordingVideoCodec_AV1; 2962 return VINF_SUCCESS; 2963 } 2964 else if (RTStrIStr(strCodec.c_str(), "other")) 2965 { 2966 enmCodec = RecordingVideoCodec_Other; 2967 return VINF_SUCCESS; 2968 } 2969 2970 AssertFailedReturn(VERR_NOT_SUPPORTED); 2971 } 2972 2973 /** 2974 * Converts a video codec to a serializable string. 2975 * 2976 * @param enmCodec Codec to convert to a string. 2977 * @param strCodec Where to return the video codec converted as a string. 2978 */ 2979 /* static */ 2980 void RecordingScreenSettings::videoCodecToString(const RecordingVideoCodec_T &enmCodec, com::Utf8Str &strCodec) 2981 { 2982 switch (enmCodec) 2983 { 2984 case RecordingVideoCodec_None: strCodec = "none"; return; 2985 case RecordingVideoCodec_MJPEG: strCodec = "MJPEG"; return; 2986 case RecordingVideoCodec_H262: strCodec = "H262"; return; 2987 case RecordingVideoCodec_H264: strCodec = "H264"; return; 2988 case RecordingVideoCodec_H265: strCodec = "H265"; return; 2989 case RecordingVideoCodec_H266: strCodec = "H266"; return; 2990 case RecordingVideoCodec_VP8: strCodec = "VP8"; return; 2991 case RecordingVideoCodec_VP9: strCodec = "VP9"; return; 2992 case RecordingVideoCodec_AV1: strCodec = "AV1"; return; 2993 case RecordingVideoCodec_Other: strCodec = "other"; return; 2994 default: AssertFailedReturnVoid(); 2995 } 2840 2996 } 2841 2997
Note:
See TracChangeset
for help on using the changeset viewer.