Java Code Examples for org.webrtc.VideoRendererGui#setView()
The following examples show how to use
org.webrtc.VideoRendererGui#setView() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoomChatPresenter.java From VideoMeeting with Apache License 2.0 | 6 votes |
public RoomChatPresenter(IRoomChatView view) { mView = view; mSocketAddress = "http://" + App.getInstance().getString(R.string.stream_host); mSocketAddress += (":" + App.getInstance().getString(R.string.stream_port) + "/"); GLSurfaceView surfaceView = mView.getSurfaceView(); surfaceView.setPreserveEGLContextOnPause(true); surfaceView.setKeepScreenOn(true); VideoRendererGui.setView(surfaceView, new Runnable() { @Override public void run() { // SurfaceView 准备完毕 L.d("eglContextReadyCallback"); init(); } }); localRender = VideoRendererGui.create( 0, 0, 50, 50, scalingType, true); }
Example 2
Source File: JanusActivity.java From janus-gateway-android with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { java.lang.System.setProperty("java.net.preferIPv6Addresses", "false"); java.lang.System.setProperty("java.net.preferIPv4Stack", "true"); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_janus); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); vsv = (GLSurfaceView) findViewById(R.id.glview); vsv.setPreserveEGLContextOnPause(true); vsv.setKeepScreenOn(true); VideoRendererGui.setView(vsv, new MyInit()); localRender = VideoRendererGui.create(72, 72, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false); remoteRender = VideoRendererGui.create(0, 0, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true); }
Example 3
Source File: RespokeCall.java From respoke-sdk-android with MIT License | 6 votes |
/** * Attach the call's video renderers to the specified GLSurfaceView * * @param glView The GLSurfaceView on which to render video */ public void attachVideoRenderer(GLSurfaceView glView) { if (null != glView) { VideoRendererGui.setView(glView, new Runnable() { @Override public void run() { Log.d(TAG, "VideoRendererGui GL Context ready"); } }); remoteRender = VideoRendererGui.create(0, 0, 100, 100, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false); localRender = VideoRendererGui.create(70, 5, 25, 25, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false); } }
Example 4
Source File: RtcActivity.java From imsdk-android with MIT License | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON | LayoutParams.FLAG_DISMISS_KEYGUARD | LayoutParams.FLAG_SHOW_WHEN_LOCKED | LayoutParams.FLAG_TURN_SCREEN_ON); this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.atom_rtc_activity_webrtc); videoEnable = getIntent().getBooleanExtra(INTENT_KEY_VIDEO_ENABLE,true); isCaller = getIntent().getBooleanExtra(INTENT_KEY_CREATEOFFER,false); from = getIntent().getExtras().getString(INTENT_KEY_FROM); to = getIntent().getExtras().getString(INTENT_KEY_TO); chatType = getIntent().getExtras().getString(INTENT_KEY_CHATTYPE); realJid = getIntent().getExtras().getString(INTENT_KEY_REALJID); LogUtil.d(TAG,"onCreate Load Tone"); initView(); EventBus.getDefault().register(this); if(videoEnable) { VideoRendererGui.setView(vsv, new Runnable() { @Override public void run() { init(); } }); } else { init(); } initCamera(); initInfo(); }
Example 5
Source File: VideoChatActivity.java From Socket.io-FLSocketIM-Android with MIT License | 5 votes |
@Override protected void initData() { super.initData(); Bundle bundle = getIntent().getExtras(); String fromUser = bundle.getString("fromUser"); String toUser = bundle.getString("toUser"); String room = bundle.getString("room"); this.fromUser = fromUser; this.toUser = toUser; this.room = room; int type = bundle.getInt("type"); videoType = type == 0?ChatVideoType.videoTypeCaller:ChatVideoType.videoTypeCallee; videoView = new GLSurfaceView(mContext); videoView.setPreserveEGLContextOnPause(true); videoView.setKeepScreenOn(true); VideoRendererGui.setView(videoView, new Runnable() { @Override public void run() { initHelper(); } }); FrameLayout layout = findViewById(R.id.video_view_back); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layout.addView(videoView, layoutParams); /* * 两者初始化顺序会影响最终渲染层的层次结构 * */ remoteRender = VideoRendererGui.create(0, 0, 100, 100, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true); localRender = VideoRendererGui.create(66, 0, 33, 33, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true); }
Example 6
Source File: RTCGLVideoView.java From q-municate-android with Apache License 2.0 | 5 votes |
private void init(TypedArray typedArray) { VideoRendererGui.setView(this, null); if (typedArray != null) { setValuefromResources(typedArray); typedArray.recycle(); } obtainMainVideoRenderer(); }
Example 7
Source File: MainActivity.java From krankygeek with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE); audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); audioManager.setSpeakerphoneOn(true); PeerConnectionFactory.initializeAndroidGlobals( this, // Context true, // Audio Enabled true, // Video Enabled true, // Hardware Acceleration Enabled null); // Render EGL Context peerConnectionFactory = new PeerConnectionFactory(); VideoCapturerAndroid vc = VideoCapturerAndroid.create(VideoCapturerAndroid.getNameOfFrontFacingDevice(), null); localVideoSource = peerConnectionFactory.createVideoSource(vc, new MediaConstraints()); VideoTrack localVideoTrack = peerConnectionFactory.createVideoTrack(VIDEO_TRACK_ID, localVideoSource); localVideoTrack.setEnabled(true); AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints()); AudioTrack localAudioTrack = peerConnectionFactory.createAudioTrack(AUDIO_TRACK_ID, audioSource); localAudioTrack.setEnabled(true); localMediaStream = peerConnectionFactory.createLocalMediaStream(LOCAL_STREAM_ID); localMediaStream.addTrack(localVideoTrack); localMediaStream.addTrack(localAudioTrack); GLSurfaceView videoView = (GLSurfaceView) findViewById(R.id.glview_call); VideoRendererGui.setView(videoView, null); try { otherPeerRenderer = VideoRendererGui.createGui(0, 0, 100, 100, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true); VideoRenderer renderer = VideoRendererGui.createGui(50, 50, 50, 50, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true); localVideoTrack.addRenderer(renderer); } catch (Exception e) { e.printStackTrace(); } }
Example 8
Source File: VideoChatActivity.java From AndroidRTC with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video_chat); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); Bundle extras = getIntent().getExtras(); if (extras == null || !extras.containsKey(Constants.USER_NAME)) { Intent intent = new Intent(this, MainActivity.class); startActivity(intent); Toast.makeText(this, "Need to pass username to VideoChatActivity in intent extras (Constants.USER_NAME).", Toast.LENGTH_SHORT).show(); finish(); return; } this.username = extras.getString(Constants.USER_NAME, ""); this.mChatList = getListView(); this.mChatEditText = (EditText) findViewById(R.id.chat_input); this.mCallStatus = (TextView) findViewById(R.id.call_status); // Set up the List View for chatting List<ChatMessage> ll = new LinkedList<ChatMessage>(); mChatAdapter = new ChatAdapter(this, ll); mChatList.setAdapter(mChatAdapter); // First, we initiate the PeerConnectionFactory with our application context and some options. PeerConnectionFactory.initializeAndroidGlobals( this, // Context true, // Audio Enabled true, // Video Enabled true, // Hardware Acceleration Enabled null); // Render EGL Context PeerConnectionFactory pcFactory = new PeerConnectionFactory(); this.pnRTCClient = new PnRTCClient(Constants.PUB_KEY, Constants.SUB_KEY, this.username); List<PeerConnection.IceServer> servers = getXirSysIceServers(); if (!servers.isEmpty()){ this.pnRTCClient.setSignalParams(new PnSignalingParams()); } // Returns the number of cams & front/back face device name int camNumber = VideoCapturerAndroid.getDeviceCount(); String frontFacingCam = VideoCapturerAndroid.getNameOfFrontFacingDevice(); String backFacingCam = VideoCapturerAndroid.getNameOfBackFacingDevice(); // Creates a VideoCapturerAndroid instance for the device name VideoCapturer capturer = VideoCapturerAndroid.create(frontFacingCam); // First create a Video Source, then we can make a Video Track localVideoSource = pcFactory.createVideoSource(capturer, this.pnRTCClient.videoConstraints()); VideoTrack localVideoTrack = pcFactory.createVideoTrack(VIDEO_TRACK_ID, localVideoSource); // First we create an AudioSource then we can create our AudioTrack AudioSource audioSource = pcFactory.createAudioSource(this.pnRTCClient.audioConstraints()); AudioTrack localAudioTrack = pcFactory.createAudioTrack(AUDIO_TRACK_ID, audioSource); // To create our VideoRenderer, we can use the included VideoRendererGui for simplicity // First we need to set the GLSurfaceView that it should render to this.videoView = (GLSurfaceView) findViewById(R.id.gl_surface); // Then we set that view, and pass a Runnable to run once the surface is ready VideoRendererGui.setView(videoView, null); // Now that VideoRendererGui is ready, we can get our VideoRenderer. // IN THIS ORDER. Effects which is on top or bottom remoteRender = VideoRendererGui.create(0, 0, 100, 100, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, false); localRender = VideoRendererGui.create(0, 0, 100, 100, VideoRendererGui.ScalingType.SCALE_ASPECT_FILL, true); // We start out with an empty MediaStream object, created with help from our PeerConnectionFactory // Note that LOCAL_MEDIA_STREAM_ID can be any string MediaStream mediaStream = pcFactory.createLocalMediaStream(LOCAL_MEDIA_STREAM_ID); // Now we can add our tracks. mediaStream.addTrack(localVideoTrack); mediaStream.addTrack(localAudioTrack); // First attach the RTC Listener so that callback events will be triggered this.pnRTCClient.attachRTCListener(new DemoRTCListener()); // Then attach your local media stream to the PnRTCClient. // This will trigger the onLocalStream callback. this.pnRTCClient.attachLocalMediaStream(mediaStream); // Listen on a channel. This is your "phone number," also set the max chat users. this.pnRTCClient.listenOn("Kevin"); this.pnRTCClient.setMaxConnections(1); // If the intent contains a number to dial, call it now that you are connected. // Else, remain listening for a call. if (extras.containsKey(Constants.CALL_USER)) { String callUser = extras.getString(Constants.CALL_USER, ""); connectToUser(callUser); } }
Example 9
Source File: AppRTCDemoActivity.java From WebRTCDemo with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Thread.setDefaultUncaughtExceptionHandler( new UnhandledExceptionHandler(this)); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); Point displaySize = new Point(); getWindowManager().getDefaultDisplay().getRealSize(displaySize); vsv = new AppRTCGLView(this, displaySize); VideoRendererGui.setView(vsv); remoteRender = VideoRendererGui.create(0, 0, 100, 100); localRender = VideoRendererGui.create(70, 5, 25, 25); vsv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleHUD(); } }); setContentView(vsv); logAndToast("Tap the screen to toggle stats visibility"); hudView = new TextView(this); hudView.setTextColor(Color.BLACK); hudView.setBackgroundColor(Color.WHITE); hudView.setAlpha(0.4f); hudView.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5); hudView.setVisibility(View.INVISIBLE); addContentView(hudView, hudLayout); if (!factoryStaticInitialized) { abortUnless(PeerConnectionFactory.initializeAndroidGlobals( this, true, true), "Failed to initializeAndroidGlobals"); factoryStaticInitialized = true; } AudioManager audioManager = ((AudioManager) getSystemService(AUDIO_SERVICE)); // TODO(fischman): figure out how to do this Right(tm) and remove the // suppression. @SuppressWarnings("deprecation") boolean isWiredHeadsetOn = audioManager.isWiredHeadsetOn(); audioManager.setMode(isWiredHeadsetOn ? AudioManager.MODE_IN_CALL : AudioManager.MODE_IN_COMMUNICATION); audioManager.setSpeakerphoneOn(!isWiredHeadsetOn); sdpMediaConstraints = new MediaConstraints(); sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( "OfferToReceiveAudio", "true")); sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( "OfferToReceiveVideo", "true")); final Intent intent = getIntent(); if ("android.intent.action.VIEW".equals(intent.getAction())) { connectToRoom(intent.getData().toString()); return; } showGetRoomUI(); }
Example 10
Source File: AppRTCDemoActivity.java From droidkit-webrtc with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Thread.setDefaultUncaughtExceptionHandler( new UnhandledExceptionHandler(this)); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); Point displaySize = new Point(); getWindowManager().getDefaultDisplay().getRealSize(displaySize); vsv = new AppRTCGLView(this, displaySize); VideoRendererGui.setView(vsv); remoteRender = VideoRendererGui.create(0, 0, 100, 100); localRender = VideoRendererGui.create(70, 5, 25, 25); vsv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toggleHUD(); } }); setContentView(vsv); logAndToast("Tap the screen to toggle stats visibility"); hudView = new TextView(this); hudView.setTextColor(Color.BLACK); hudView.setBackgroundColor(Color.WHITE); hudView.setAlpha(0.4f); hudView.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5); hudView.setVisibility(View.INVISIBLE); addContentView(hudView, hudLayout); if (!factoryStaticInitialized) { abortUnless(PeerConnectionFactory.initializeAndroidGlobals( this, true, true), "Failed to initializeAndroidGlobals"); factoryStaticInitialized = true; } AudioManager audioManager = ((AudioManager) getSystemService(AUDIO_SERVICE)); // TODO(fischman): figure out how to do this Right(tm) and remove the // suppression. @SuppressWarnings("deprecation") boolean isWiredHeadsetOn = audioManager.isWiredHeadsetOn(); audioManager.setMode(isWiredHeadsetOn ? AudioManager.MODE_IN_CALL : AudioManager.MODE_IN_COMMUNICATION); audioManager.setSpeakerphoneOn(!isWiredHeadsetOn); sdpMediaConstraints = new MediaConstraints(); sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( "OfferToReceiveAudio", "true")); sdpMediaConstraints.mandatory.add(new MediaConstraints.KeyValuePair( "OfferToReceiveVideo", "true")); final Intent intent = getIntent(); if ("android.intent.action.VIEW".equals(intent.getAction())) { connectToRoom(intent.getData().toString()); return; } showGetRoomUI(); }