Pass tab media stream to another tab (chrome.tabCapture)

1,687 views
Skip to first unread message

pablo

unread,
Jun 30, 2015, 4:16:41 AM6/30/15
to discuss...@googlegroups.com
Hi,

Is it possible to share a MediaStream captured with chrome.tabCapture with another tab?
My use case is a meeting session in a chrome tab (peer connection).
The user will click a button in the meeting to 'share a browser tab'.
Chrome will open a new tab, create a media stream with chrome.tabCapture and pass it to the meeting tab.
The meeting tab will add the media stream to the meeting peer connection.

Thanks

Christoffer Jansson

unread,
Jul 2, 2015, 9:11:21 AM7/2/15
to discuss...@googlegroups.com, pablo...@gmail.com
Hi,

Yes you can attach a stream from chrome.tabCapture (you need to do this from an extension and provide the tab id of the tab you want to capture) into an active peerconnection, just stop and remove the current stream then attach the tabCapture stream.

Api details here.

Did a quick search and found this github repo, I've not tried it myself but you could take a look and see if it has any useful info.

/Chris

pablo platt

unread,
Jul 2, 2015, 9:22:16 AM7/2/15
to discuss...@googlegroups.com
On Thu, Jul 2, 2015 at 4:11 PM, Christoffer Jansson <jan...@google.com> wrote:
Hi,

Yes you can attach a stream from chrome.tabCapture (you need to do this from an extension and provide the tab id of the tab you want to capture) into an active peerconnection, just stop and remove the current stream then attach the tabCapture stream.

Api details here.

I have two tabs:
Meeting tab.
Captured tab (will be created when needed).

I want to click a button in the meeting tab, create the captured tab and capture it.
Is it possible?
 

Did a quick search and found this github repo, I've not tried it myself but you could take a look and see if it has any useful info.

In this example, you click a browser button while the tab you want to share is active. I want to start sharing from another tab.
 

/Chris

On Tuesday, June 30, 2015 at 10:16:41 AM UTC+2, pablo wrote:
Hi,

Is it possible to share a MediaStream captured with chrome.tabCapture with another tab?
My use case is a meeting session in a chrome tab (peer connection).
The user will click a button in the meeting to 'share a browser tab'.
Chrome will open a new tab, create a media stream with chrome.tabCapture and pass it to the meeting tab.
The meeting tab will add the media stream to the meeting peer connection.

Thanks

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/c2846f93-5a87-406b-b27f-ffb8b6d2ec9f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Christoffer Jansson

unread,
Jul 2, 2015, 9:47:00 AM7/2/15
to discuss...@googlegroups.com
On Thu, Jul 2, 2015 at 3:22 PM pablo platt <pablo...@gmail.com> wrote:
On Thu, Jul 2, 2015 at 4:11 PM, Christoffer Jansson <jan...@google.com> wrote:
Hi,

Yes you can attach a stream from chrome.tabCapture (you need to do this from an extension and provide the tab id of the tab you want to capture) into an active peerconnection, just stop and remove the current stream then attach the tabCapture stream.

Api details here.

I have two tabs:
Meeting tab.
Captured tab (will be created when needed).

I want to click a button in the meeting tab, create the captured tab and capture it.
Is it possible?
Yes it is as I mentioned you start the capture FROM the meeting tab in your example and provide the tab ID of the tab you want to capture, Captured tab in your case, the meeting tab will have access to both the mediaStream and the peerconnection object. 

If the tab does not exist before sharing you have to create it using chrome.tab extension api and get the tab id from it.
 

Did a quick search and found this github repo, I've not tried it myself but you could take a look and see if it has any useful info.

In this example, you click a browser button while the tab you want to share is active. I want to start sharing from another tab.
 

/Chris

On Tuesday, June 30, 2015 at 10:16:41 AM UTC+2, pablo wrote:
Hi,

Is it possible to share a MediaStream captured with chrome.tabCapture with another tab?
My use case is a meeting session in a chrome tab (peer connection).
The user will click a button in the meeting to 'share a browser tab'.
Chrome will open a new tab, create a media stream with chrome.tabCapture and pass it to the meeting tab.
The meeting tab will add the media stream to the meeting peer connection.

Thanks

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.

pablo platt

unread,
Jul 2, 2015, 10:07:59 AM7/2/15
to discuss...@googlegroups.com
On Thu, Jul 2, 2015 at 4:46 PM, 'Christoffer Jansson' via discuss-webrtc <discuss...@googlegroups.com> wrote:


On Thu, Jul 2, 2015 at 3:22 PM pablo platt <pablo...@gmail.com> wrote:
On Thu, Jul 2, 2015 at 4:11 PM, Christoffer Jansson <jan...@google.com> wrote:
Hi,

Yes you can attach a stream from chrome.tabCapture (you need to do this from an extension and provide the tab id of the tab you want to capture) into an active peerconnection, just stop and remove the current stream then attach the tabCapture stream.

Api details here.

I have two tabs:
Meeting tab.
Captured tab (will be created when needed).

I want to click a button in the meeting tab, create the captured tab and capture it.
Is it possible?
Yes it is as I mentioned you start the capture FROM the meeting tab in your example and provide the tab ID of the tab you want to capture, Captured tab in your case, the meeting tab will have access to both the mediaStream and the peerconnection object. 

From the docs it's not clear what tab I'm able to capture.
Doesn't the activeTab permission mean that the capture has to be started by a user action from the Captured tab?

Chrome issue about tabCapture docs not clear enough:
https://code.google.com/p/chromium/issues/detail?id=451723

activeTab permission
https://developer.chrome.com/extensions/activeTab

Christoffer Jansson

unread,
Jul 2, 2015, 10:26:56 AM7/2/15
to discuss...@googlegroups.com
On Thu, Jul 2, 2015 at 4:07 PM pablo platt <pablo...@gmail.com> wrote:
On Thu, Jul 2, 2015 at 4:46 PM, 'Christoffer Jansson' via discuss-webrtc <discuss...@googlegroups.com> wrote:


On Thu, Jul 2, 2015 at 3:22 PM pablo platt <pablo...@gmail.com> wrote:
On Thu, Jul 2, 2015 at 4:11 PM, Christoffer Jansson <jan...@google.com> wrote:
Hi,

Yes you can attach a stream from chrome.tabCapture (you need to do this from an extension and provide the tab id of the tab you want to capture) into an active peerconnection, just stop and remove the current stream then attach the tabCapture stream.

Api details here.

I have two tabs:
Meeting tab.
Captured tab (will be created when needed).

I want to click a button in the meeting tab, create the captured tab and capture it.
Is it possible?
Yes it is as I mentioned you start the capture FROM the meeting tab in your example and provide the tab ID of the tab you want to capture, Captured tab in your case, the meeting tab will have access to both the mediaStream and the peerconnection object. 

From the docs it's not clear what tab I'm able to capture.
Doesn't the activeTab permission mean that the capture has to be started by a user action from the Captured tab?
Maybe you could try it out?

pablo platt

unread,
Jul 2, 2015, 10:31:03 AM7/2/15
to discuss...@googlegroups.com
On Thu, Jul 2, 2015 at 5:26 PM, 'Christoffer Jansson' via discuss-webrtc <discuss...@googlegroups.com> wrote:


On Thu, Jul 2, 2015 at 4:07 PM pablo platt <pablo...@gmail.com> wrote:
On Thu, Jul 2, 2015 at 4:46 PM, 'Christoffer Jansson' via discuss-webrtc <discuss...@googlegroups.com> wrote:


On Thu, Jul 2, 2015 at 3:22 PM pablo platt <pablo...@gmail.com> wrote:
On Thu, Jul 2, 2015 at 4:11 PM, Christoffer Jansson <jan...@google.com> wrote:
Hi,

Yes you can attach a stream from chrome.tabCapture (you need to do this from an extension and provide the tab id of the tab you want to capture) into an active peerconnection, just stop and remove the current stream then attach the tabCapture stream.

Api details here.

I have two tabs:
Meeting tab.
Captured tab (will be created when needed).

I want to click a button in the meeting tab, create the captured tab and capture it.
Is it possible?
Yes it is as I mentioned you start the capture FROM the meeting tab in your example and provide the tab ID of the tab you want to capture, Captured tab in your case, the meeting tab will have access to both the mediaStream and the peerconnection object. 

From the docs it's not clear what tab I'm able to capture.
Doesn't the activeTab permission mean that the capture has to be started by a user action from the Captured tab?
Maybe you could try it out?

I can and I will but even if it'll work, it might be a security risk.
If an extension can open a tab with arbitrary URL with sensitive info and share it just by clicking on a button in another tab, it might be a problem.
That's the reason I'm trying to understand the docs and what should be possible before investing time in doing stuff that is possible by accident and will be changed sooner or later.
 

Christoffer Jansson

unread,
Jul 2, 2015, 10:34:21 AM7/2/15
to discuss...@googlegroups.com
On Thu, Jul 2, 2015 at 4:31 PM pablo platt <pablo...@gmail.com> wrote:
On Thu, Jul 2, 2015 at 5:26 PM, 'Christoffer Jansson' via discuss-webrtc <discuss...@googlegroups.com> wrote:


On Thu, Jul 2, 2015 at 4:07 PM pablo platt <pablo...@gmail.com> wrote:
On Thu, Jul 2, 2015 at 4:46 PM, 'Christoffer Jansson' via discuss-webrtc <discuss...@googlegroups.com> wrote:


On Thu, Jul 2, 2015 at 3:22 PM pablo platt <pablo...@gmail.com> wrote:
On Thu, Jul 2, 2015 at 4:11 PM, Christoffer Jansson <jan...@google.com> wrote:
Hi,

Yes you can attach a stream from chrome.tabCapture (you need to do this from an extension and provide the tab id of the tab you want to capture) into an active peerconnection, just stop and remove the current stream then attach the tabCapture stream.

Api details here.

I have two tabs:
Meeting tab.
Captured tab (will be created when needed).

I want to click a button in the meeting tab, create the captured tab and capture it.
Is it possible?
Yes it is as I mentioned you start the capture FROM the meeting tab in your example and provide the tab ID of the tab you want to capture, Captured tab in your case, the meeting tab will have access to both the mediaStream and the peerconnection object. 

From the docs it's not clear what tab I'm able to capture.
Doesn't the activeTab permission mean that the capture has to be started by a user action from the Captured tab?
Maybe you could try it out?

I can and I will but even if it'll work, it might be a security risk.
If an extension can open a tab with arbitrary URL with sensitive info and share it just by clicking on a button in another tab, it might be a problem.
That's the reason I'm trying to understand the docs and what should be possible before investing time in doing stuff that is possible by accident and will be changed sooner or later.

Maybe let the user choose instead? Try the chrome.desktopCapture api and let the user choose which window/tab/desktop to share.

pablo platt

unread,
Jul 2, 2015, 10:43:34 AM7/2/15
to discuss...@googlegroups.com
The chrome.desktopCapture API is much better for my use case but I couldn't make audio work with it.
The nice thing about chrome.tabCapture is that it works well with audio.
What will be nice is if chrome.desktopCapture will support 'tab' in addition to screen and window.
When capturing a tab, it could use the tabCapture code only with the desktop's window chooser UI.

Audio is supposed to work with chrome.desktopCapture but it's probably tested only with Chromecast.
https://code.google.com/p/chromium/issues/detail?id=223639

I could make audio work only when capturing the entire screen, not a single app.
Even than, it doesn't work all the time. For example, it doesn't work headset connected to the front jacks, only with speakers connected to the rear connections.

'audio': {
  'mandatory': {
    'chromeMediaSource': 'system',
    'chromeMediaSourceId': tabId
   }
}

TJ Singleton

unread,
Jul 2, 2015, 5:23:05 PM7/2/15
to discuss...@googlegroups.com

> From the docs it's not clear what tab I'm able to capture.
> Doesn't the activeTab permission mean that the capture has to be started by a user action from the Captured tab?

Based on my experimentation it has to be in response to a user action. https://developer.chrome.com/extensions/activeTab lists some examples.

The following user gestures enable activeTab:

• Executing a browser action
• Executing a page action
• Executing a context menu item
• Executing a keyboard shortcut from the commands API
• Accepting a suggestion from the omnibus API

--
TJ Singleton
t...@clearslide.com


pablo platt

unread,
Jul 2, 2015, 5:46:46 PM7/2/15
to discuss...@googlegroups.com
A user action in which tab? The tab you are going to capture or, in my case, the application (meeting) tab?
 

--
TJ Singleton
t...@clearslide.com



--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages