Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Webcam Subsscriber / Publisher

Avatar

Level 3
Hi,



Looking at the Webcam example and the WebcamPublisher i can
not find a way to set the size and resolution of the input flux and
output flux. It stays as a square, like in the example with a low
quality.

I guess that is a beta limitation but i would like to make
sure.



An other question on a use case.



Since i will 'limit' our sessions to two users for now i am
trying to display streams as follow:

A small video of myself in the corner of a larger area
receiving an audio video stream from an other user.

I got the gui working.



<rtc:WebcamSubscriber> uses webcamPublisher="{camPub}"
where camPub is the <rtc:WebcamPublisher on my connectSession.



If two users are publishing such as Alice and Bob my

<rtc:WebcamSubscriber> will show two users in the large
"Subscribing" video container area.



I see that i could limit the publishers i am looking at by
using the publisherIDs array attributes.

I am wondering on how to get all users ids from my room ?



So i will have two <rtc:WebcamSubscriber> one limited
to myself to see the local version, and one larger limited to the
first extra user id (there should not be more than two for now).
Will that work ?



Again is it possible not to get a square video flux but a
more standard one like 160*120 or 320*240 ?



Thanks for the enlightenment.



Greg







12 Replies

Avatar

Level 10
Hi,

Regarding the second part of your question,

By default, if you don't set the publisherIDs, the
WebcamSubscriber shows all streams.

If you set the publisherIDs property(array) in
WebCamSubscriber, it will show only those streams whose
streamPublisherIDs are those you have in this array. The
StreamPublisherIDs or the publisherIDs you can get from the
userManager, they are nothing but userIDs of the Users. You can
call userManager.userCollection and get all the userDescriptors and
iterate over it to get the userIDs and use those ids as
publisherIDs.



So, if you want to show one user in small, and two others
users in large, you can use one webcamsubscriber for the small
image with its publisherIDs property has just one value, i.e. the
userID of the User who is publishing the small image.

For the other two users, you can use another WebcamSubscriber
with its large width and height and its publisherIDs has userIDs of
those two other users.



I will update the first part of question is in a subsequent
post.



Thanks

Hironmay Basu

Avatar

Level 3
Thanks for the tips.

Now i just need nicer resolutions and it will be perfect
🙂

Avatar

Level 10
Hi Greg,



There are two different ways you can solve this problem (size
and resolution of input flux).

There is a property called aspectRatio i.e. width/height in
StreamManager which by default is set to Standard i.e. width and
height being the same. There are two other values we support, the
portrait and landscape, whos width and height and the ratio you can
look at the StreamManager class in the constants defined.

Based on the aspectRatio, the width and height of the streams
are calculated in layoutStreams() and its associated function in
WebCamSubscirber. Since the default is Standard, you see square
values.



Now, if your job can be done just by specifying the width to
height ratio i.e. aspectRatio, you can use the StreamManager API (
also defined in WebCamera ) to set the required ratio of your
width/height.

And if you want to completely specify your own width and
height, you need to override the WebCamSubscriber class and its
layoutStreams and associated functions. It is in the
layoutStreams() function where we calculate based on number of
Streams, the number of rows/columns required to layout the streams.

Hope this helps. Please let me know if you need any other
info.



Thanks

Hironmay Basu



Avatar

Level 10
Hi,



One more thing I wanted to add is the quality setting. You
can change the quality of image using the WebcamPublisher API that
increases the camera quality. We use a value of 70, however you can
use upto 100 to increase your quality of camera.

Thanks

Hironmay Basu

Avatar

Level 3
Hello Hironmay,



I got it working but i have few questions.



First an unrelated one:

In WebcamSubscriber.as line 18 there is

import com.adobe.rtc.core.session_internal ;



Is that a way to access the current session object ?

currently we were using "this.session =
mx.core.Application.application.sessionContainer;"



My rooms will not have more than 2 users right now, so i did
the following layout
http://coulix.net/temp/test_coco_cam.png.



In the top right i use a WebcamSubscriber called "localSub"

with webcamPublisher set to "camPub" my cam publisher.



I set the width and height of "localSub" WebcamSubscriber to
80*60, set the StreamManager aspectRatio to Portrait, and restrict
the publisherIds to the id of myself.



Question:

Is that the simplest way of showing my own stream or should i
go for a video container with my local_cam instead ?.



For the largest WebcamSubscriber i called remoteSub i did
extend WebcamSubscriber and set up a super simple layout function
working for on video container only with:



override protected function layoutCameraStreams():void

{

streamDescriptors:Object=_streamManager.getStreamsOfType(StreamManager.CAMERA_STREAM);

for (var id:String in _streamDescriptorTable) {

if( _videoTable[id] != null) {

var vC:VideoComponent = _videoTable[id];

vC.width=250;

vC.height=188;/



}

}

}



Question:

Since i set StreamManager aspect ratio what is the resolution
of the stream i am actually sending, PORTRAIT size ? 144*98



The video component i set size is just a zoom on the 144*98 i
guess, and not a resolution increase.



Should i override

protected function set webCamera(p_camera:Camera):void

and set the resolution there ?



And one last question.

I tried to play with "changeSizeStream"

Does the last argument is the User ID of the stream owner or
the streamPublisherID ?

session.streamManager.changeSizeStream(

StreamManager.CAMERA_STREAM, 288, 224,
streamDescriptor.streamPublisherID);

It did not seem to change in my case.



Thanks a lot.



Greg











Avatar

Level 10


Hi Greg,



I'll answer some of this, and Hironmay will fill in the
details :



session_internal is really just a way to get a hold of the
netConnection. In general, we abstract away access to these,
because we are sometimes forced to throw away netconnections and
re-create them, and any outside ref to them can become invalid. So,
we "protect" them to keep devs away from that pain.



If you need access to the IConnectSession, every
ISessionSubscriber component has a .connectSession property (this
way, you can have one webcam inside one connectSession, and another
in another connectSession, in the same app!).



The simplest way of showing your own stream should be to set
the .webcamPublisher property in WebcamSubscriber. This will cause
your own local stream to appear w/o going through the network.



Hopefully I got those answers right (Hironmay is the owner
of the pub/sub components, and will know more).



nigel



Avatar

Level 10
Hi,



I will try to answer your questions here :

>I set the width and height of "localSub" WebcamSubscriber
to 80*60, set the StreamManager aspectRatio to >Portrait, and
restrict the publisherIds to the id of myself.

>Is that the simplest way of showing my own stream or
should i go for a video container with my local_cam instead ?.



When you set the width and height of WebcamSubscriber to
80*60 and a portrait ( i.e. 144/112 i.e. 1.28) ratio. So, while
laying out the stream , since its just one stream it will try to
take the max width i.e 80 and height of 80/1.28 for it i.e. in this
case 62.5 since this is more than 60, it will take a height of 60
and a width of 60 *1.28 = 76.8 . Currently , this is the simplest
way of showing your image. While showing your own image, we
directly go through the camera ( as nigel mentioned ) w/o appearing
over network to prevent unnecessary bandwidth use.

Note: You can always override the WebcamSubscriber completely
to use your own directly hooked to StreamManager if your
requirement is very simple but that will involve some work , so I
guess what you are currently doing is correct.



>Question:

>Since i set StreamManager aspect ratio what is the
resolution of the stream i am actually sending, PORTRAIT >size ?
144*98



We use the aspectRatio values only while calculatng layout in
functions computeArea_Rows and computeArea_Columns functions which
are called from layoutStreams() which you are already overridding,
so whatever width and height you are setting for the stream ( in
this case 250 and 188) , your size will be the same and setting any
aspectRatio will have no effect.



>Does the last argument is the User ID of the stream owner
or the streamPublisherID ?



As in a previous reply, the streamPublisherIDs are same as
the userIDs of users who published the stream. If you already have
the streamDescriptor, you can just pass the
streamDesc.streamPublisherID as an arguement while calling this
function. Let me know if you can get it to work, else I will test
it locally.



Thanks

Hironmay



Note: As an added info, you might want to take a look at the
new zoomLayout example in the just released drop of SDK. You will
find we are using a customized WebcamSubscriber(MyWebcamSubscriber)
for laying out and animating the streams.

Avatar

Level 3
Hi Hironmay,



I got it working perfectly, on top right corner a
WebcamSubscriber set my local cam publisher on my own subscriber
ID.

And the large view being a custom WebcamSubscriber just
changing the layout rules with the subscribers set to the other
person in the room. Also reacting to USER_CREATE and USER_REMOVE to
update the publiserIds list accordingly.



However with a quality of 80 i got this:


http://www.coulix.net/temp/cam_test_2.png



Setting it to 100 dramatically improved it, i will have to
see the result in the room manager stats graph.



Thanks again,



Greg



Avatar

Level 2
How can I get sound to work with the webcampublisher? I have
started with the webcamera example. There is no sound only video.
So I followed the same pattern where the webcamsubscriber and
webcampublisher are and added audio with AudioSubscriber and
AudioPublisher. I seem to get sound but have an issue with keeping
track of the users. I have a ListCollectionView object monitoring
the cSession.userManager.userCollection. This works great when only
the WebcamPublisher exists. As soon as I add in the AudioPublisher
then I get remove and add events for the same user. This causes my
list which is listening to create new renderers and I lose my
states for each. This happens following the webcam.publish,
audio.publish. Is this expected behavior? Should I be adding my
audio in a different way?

Avatar

Level 10
Hi,



I guess what you are doing seems correct. You need to use
AudioPublisher and AudioSubscriber for audio and WebcamPublisher
and WebcamSubscriber for video. Now, regarding userCollection,
UserCollection does change when you publish audio since the
userDescriptor of the user changes ( he gets added customFields
like audio/camera to have info that a user is speaking/sharing
camera). So, you will get events UserAdded and UserRemoved when a
publish audio/camera happens as it will clean and update the
UserDescriptor with new fields for that user. This explains why you
are getting add and remove events for the same user. Can you stop
listening for that user while you are publishing ? It's an
interesting case, and we will definitely think over ways if we can
on our side let the user decide if they want to have those
customFields like audio/video.



Thanks

Hironmay Basu

Avatar

Level 3

Hi Basu,

Can you clarify something for me, although I'm pretty sure this is the case.

For the case where I only want to show my own local webcam I should:

Create a WebcamSubscriber and set the .webcamPublisher to be my own local publisher.

In order to save bandwidth cost I should just set the list of publisherIds to ONLY contain my own userId. The api knows that I only want to display myself and will NOT subscribe to the stream I am publishing but will just show the webcam stream from the local webcam?

The point I wanted to clarify was that it is correct to set the list of publisherIds to only have my own userId... or can I set it to some other value to tell it NOT to subscribe to any publishers other than the local one?

Thanks,

Barry

Avatar

Level 10

Hi Barry,

Yes you are right. You need to just set the publisherIDs to your own userID. It will then not subscribe to streams of any other user. And since, its only your stream, it will be taken locally.

Hope this helps

Thanks

Hironmay Basu