0

I am working in one application, In which I am using tokbox for the video calling, But before displaying the Active call screen, I need to show the front camera preview to the user. Using tokbox publisher we can't do that otherwise, the video will reach the end user before call accept.

So How can we show Front Camera Video preview(Just the preview, I don't need any capturing or anything) in the framelayout using Camera2 API of Android?

Siraj Sumra
  • 934
  • 1
  • 11
  • 28

2 Answers2

1

You can get a preview from the Publisher by calling Publisher.startPreview(). This will start the camera and put it on the Publisher.getView() that you can put in your UI.

Don't forget to do Publisher.destory() if you do this. I didn't do that at first and noticed issues of the camera not being released correctly after TokBox sessions on older (non-Camera2) devices.

Lance Johnson
  • 1,226
  • 12
  • 8
  • If you do Publisher.startPreview(), It will publish the data in the session. I don't want to Publish it. – Siraj Sumra Dec 26 '17 at 12:35
  • Perhaps you are confusing the connecting to the session with publishing your stream. Just connecting to the session does not automatically publish the stream when you call `publisher.startPreview()`. My app adds a `SessionListener` to the session. When a connection happens I build my publisher and call `startPreview()` on it. I do not call `session.publish(publisher)`. I do that later when I am ready to publish the stream to the session. – Lance Johnson Feb 08 '18 at 19:37
0

You can use instantiate the publisher and use it's view, and not publish to the session initially.

Jaideep Shah
  • 146
  • 3