@@ -1927,6 +1927,19 @@ public LiveTranscoding.VideoCodecProfileType getLiveTranscodingVideoCodecProfile
19271927 return type ;
19281928 }
19291929
1930+ public LiveTranscoding .AudioCodecProfileType getLiveTranscodingAudioCodecProfileEnum (int val ) {
1931+ LiveTranscoding .AudioCodecProfileType type = LiveTranscoding .AudioCodecProfileType .LC_AAC ;
1932+ switch (Integer .valueOf (val )) {
1933+ case 0 :
1934+ type = LiveTranscoding .AudioCodecProfileType .LC_AAC ;
1935+ break ;
1936+ case 1 :
1937+ type = LiveTranscoding .AudioCodecProfileType .HE_AAC ;
1938+ break ;
1939+ }
1940+ return type ;
1941+ }
1942+
19301943
19311944
19321945 @ ReactMethod
@@ -1994,7 +2007,7 @@ public void removePublishStreamUrl(ReadableMap options, Promise promise) {
19942007 @ ReactMethod
19952008 public void setLiveTranscoding (ReadableMap options , Promise promise ) {
19962009 LiveTranscoding transcoding = new LiveTranscoding ();
1997- if (options .hasKey ("size" ) && null != options . getMap ( "size" ) ) {
2010+ if (options .hasKey ("size" )) {
19982011 ReadableMap size = options .getMap ("size" );
19992012 transcoding .width = size .getInt ("width" );
20002013 transcoding .height = size .getInt ("height" );
@@ -2014,64 +2027,61 @@ public void setLiveTranscoding(ReadableMap options, Promise promise) {
20142027 if (options .hasKey ("videoCodecProfile" )) {
20152028 transcoding .videoCodecProfile = getLiveTranscodingVideoCodecProfileEnum (options .getInt ("videoCodecProfile" ));
20162029 }
2017- if (options .hasKey ("transcodingUsers" )) {
2018- ArrayList <LiveTranscoding .TranscodingUser > users = new ArrayList <LiveTranscoding .TranscodingUser >();
2019- ReadableArray transcodingUsers = options .getArray ("transcodingUsers" );
2020- for (int i = 0 ; i < transcodingUsers .size (); i ++) {
2021- ReadableMap _map = transcodingUsers .getMap (i );
2022- LiveTranscoding .TranscodingUser user = new LiveTranscoding .TranscodingUser ();
2023- user .uid = _map .getInt ("uid" );
2024- ReadableMap backgroundColor = _map .getMap ("backgroundColor" );
2025- user .x = backgroundColor .getInt ("x" );
2026- user .y = backgroundColor .getInt ("y" );
2027- user .width = backgroundColor .getInt ("width" );
2028- user .height = backgroundColor .getInt ("height" );
2029- user .zOrder = _map .getInt ("zOrder" );
2030- user .alpha = _map .getInt ("alpha" );
2031- user .audioChannel = _map .getInt ("audioChannel" );
2032- users .add (user );
2033- }
2034- transcoding .setUsers (users );
2030+ if (options .hasKey ("audioCodecProfile" )) {
2031+ transcoding .audioCodecProfile = getLiveTranscodingAudioCodecProfileEnum (options .getInt ("audioCodecProfile" ));
20352032 }
2036- if (options .hasKey ("transcodingExtraInfo " )) {
2037- transcoding .userConfigExtraInfo = options .getString ( "transcodingExtraInfo" );
2033+ if (options .hasKey ("audioSampleRate " )) {
2034+ transcoding .audioSampleRate = getLiveTranscodingAudioSampleRateEnum ( options .getInt ( "audioSampleRate" ) );
20382035 }
20392036 if (options .hasKey ("watermark" )) {
20402037 ReadableMap watermark = options .getMap ("watermark" );
20412038 WritableMap map = Arguments .createMap ();
20422039 map .putString ("url" , watermark .getString ("url" ));
2043- map .putString ("x" , watermark .getString ("x" ));
2044- map .putString ("y" , watermark .getString ("y" ));
2045- map .putString ("width" , watermark .getString ("width" ));
2046- map .putString ("height" , watermark .getString ("height" ));
2040+ map .putInt ("x" , watermark .getInt ("x" ));
2041+ map .putInt ("y" , watermark .getInt ("y" ));
2042+ map .putInt ("width" , watermark .getInt ("width" ));
2043+ map .putInt ("height" , watermark .getInt ("height" ));
20472044 transcoding .watermark = createAgoraImage (map );
20482045 }
20492046 if (options .hasKey ("backgroundImage" )) {
2050- ReadableMap watermark = options .getMap ("backgroundImage" );
2047+ ReadableMap image = options .getMap ("backgroundImage" );
20512048 WritableMap map = Arguments .createMap ();
2052- map .putString ("url" , watermark .getString ("url" ));
2053- map .putString ("x" , watermark . getString ("x" ));
2054- map .putString ("y" , watermark . getString ("y" ));
2055- map .putString ("width" , watermark . getString ("width" ));
2056- map .putString ("height" , watermark . getString ("height" ));
2049+ map .putString ("url" , image .getString ("url" ));
2050+ map .putInt ("x" , image . getInt ("x" ));
2051+ map .putInt ("y" , image . getInt ("y" ));
2052+ map .putInt ("width" , image . getInt ("width" ));
2053+ map .putInt ("height" , image . getInt ("height" ));
20572054 transcoding .backgroundImage = createAgoraImage (map );
20582055 }
20592056 if (options .hasKey ("backgroundColor" )) {
2060- ReadableMap backgroundColor = options .getMap ("backgroundColor" );
2061- transcoding .setBackgroundColor (
2062- backgroundColor .getInt ("red" ),
2063- backgroundColor .getInt ("green" ),
2064- backgroundColor .getInt ("blue" )
2065- );
2066- }
2067- if (options .hasKey ("audioSampleRate" )) {
2068- transcoding .audioSampleRate = getLiveTranscodingAudioSampleRateEnum (options .getInt ("audioSampleRate" ));
2057+ transcoding .setBackgroundColor (options .getInt ("backgroundColor" ));
20692058 }
20702059 if (options .hasKey ("audioBitrate" )) {
2071- transcoding .audioChannels = options .getInt ("audioBitrate" );
2060+ transcoding .audioBitrate = options .getInt ("audioBitrate" );
20722061 }
20732062 if (options .hasKey ("audioChannels" )) {
2074- transcoding .audioChannels = options .getInt ("audioChannel" );
2063+ transcoding .audioChannels = options .getInt ("audioChannels" );
2064+ }
2065+ if (options .hasKey ("transcodingUsers" )) {
2066+ ArrayList <LiveTranscoding .TranscodingUser > users = new ArrayList <LiveTranscoding .TranscodingUser >();
2067+ ReadableArray transcodingUsers = options .getArray ("transcodingUsers" );
2068+ for (int i = 0 ; i < transcodingUsers .size (); i ++) {
2069+ ReadableMap optionUser = transcodingUsers .getMap (i );
2070+ LiveTranscoding .TranscodingUser user = new LiveTranscoding .TranscodingUser ();
2071+ user .uid = optionUser .getInt ("uid" );
2072+ user .x = optionUser .getInt ("x" );
2073+ user .y = optionUser .getInt ("y" );
2074+ user .width = optionUser .getInt ("width" );
2075+ user .height = optionUser .getInt ("height" );
2076+ user .zOrder = optionUser .getInt ("zOrder" );
2077+ user .alpha = (float ) optionUser .getDouble ("alpha" );
2078+ user .audioChannel = optionUser .getInt ("audioChannel" );
2079+ users .add (user );
2080+ }
2081+ transcoding .setUsers (users );
2082+ }
2083+ if (options .hasKey ("transcodingExtraInfo" )) {
2084+ transcoding .userConfigExtraInfo = options .getString ("transcodingExtraInfo" );
20752085 }
20762086 Integer res = AgoraManager .getInstance ().mRtcEngine .setLiveTranscoding (transcoding );
20772087 if (res == 0 ) {
@@ -2405,4 +2415,4 @@ private void sendEvent(ReactContext reactContext,
24052415 .getJSModule (DeviceEventManagerModule .RCTDeviceEventEmitter .class )
24062416 .emit (agoraEvtName .toString (), params );
24072417 }
2408- }
2418+ }
0 commit comments