Anbox video stream

Hello,
I am running the meeting app on the anbox emulator.
How can I get the incoming video stream(opponent caller’s video stream)? (to deliver it to somewhere)

Thanks in advance.

Hey alexmusichen
I don’t entirely understand the question.
Do you mean you were unable to the video stream from the remote peer during the meeting app runtime? or you are able to get the video stream from the opponent caller but want to redirect it to somewhere else?

BR
Gary

Hi Gary.
Thanks for your reply.

or you are able to get the video stream from the opponent caller but want to redirect it to somewhere else?

Yes, meeting app display opponent caller.
But I would like to redirect opponent caller’s stream to somewhere else!

Best regards.

Alex.

Hello Alex,

I have moved your post to the Anbox Cloud > users category as that is a newly created forum for questions from Anbox Cloud users.

Thanks,
Keirthana

Okay, I understand your question.
Based on your requirement, which routes the incoming video stream from an Android application to somewhere else, this’s really an Android application-level specific feature, which is out of our support scope. Anbox Cloud provides a generic AOSP experience, meaning if you find a feature that works fine on AOSP(GSI image) but doesn’t work out on Anbox Cloud or a bug you find out during Anbox container runtime, please reach out to us with the bug report.

BR
Gary

Hi Gary.
That makes sense.

Btw, I know that we can create the session that can be used for streaming.
But I could create the session based on the application.

Is there a way to create the session based on the already created container?

Best regards.

Alex.

Hey Alex
If I understand correctly, would you like to join an existing session created before? If so, you could

  1. create a joinable session.
    const connector = new AnboxStreamGatewayConnector({
        url: '<gateway_url>',
        authToken: '<auth_token>',
        session: {
            app: '<apk-name>',
            joinable: true,
            idle_time_min: 0,
        },
       ...
       ...
    });

    let stream = new AnboxStream({
        connector: connector,
        ...
        ...
    });
  1. Store the session info when creating a new session for the first time.
const sessionInfo = stream.connect();
  1. Join the existing session later. In this case, instead of supplying the apk-name to the session parameters, give the session id instead.
    const connector = new AnboxStreamGatewayConnector({
        url: '<gateway_url>',
        authToken: '<auth_token>',
        session: {
            id: sessionInfo.id,
        },
       ...
       ...
    });

    let stream = new AnboxStream({
        connector: connector,
        ...
        ...
    });
   stream.connect();

If I misunderstood the use case, please provide more details.
Thanks

BR
Gary

Hey Gary.
I created the container based on the application.
amc launch <application id>
It was created without any apk, so we can say it’s just a fresh android emulator.
I wanted to stream this fresh emulator’s screen.
I hope this would make sense to you.

Best regards.

Alex.

Hey Alex
I got your point.
Using the amc launch won’t work here.
A complete webrtc session requires going through signaling process, which involves the stream gateway + stream agent to exchange the session metadata.

Regarding your use case, you could

  1. Create an apk less application either from the ams node or from the anbox cloud dashboard.
  2. Launch a session with the newly created application from anbox cloud dashboard.

Then it should be working out of the box.

BR
Gary

Hey Gary.

Thanks for your explanation.
So I got that the container created by amc launch can’t be used for streaming.

When the session was created, I saw that it created its mapping container.
Is there a way to allow the access to this container? ssh and adb

Best regards.

Alex.

The easiest way to access that container is to use

amc shell <container_id>

command.
Then dump the Android log with

$ anbox-shell logcat

NOTE: If you’re running regular Anbox Cloud deployment rather than an appliance, you need to jump to ams node first with juju ssh ams/0 command

You could also refer to the How to access a container doc for more details.

BR
Gary

Hi Gary.
Thanks for your support.
Not an way to allow adb access?

Best regards.

Alex.

If you follow the above doc I mentioned above, you could easily setup adb access to a running container from a local machine.
So basically, what you can do is that

  1. When creating an application, in the application manifest file, you expose the adb service as follows:

    name: <your_app_name>
    instance-type: <instance_type>
    image: <image_name>
    services:
    - name: adb
      expose: true
      port: 5559
      protocols: [tcp]
    ...
    
  2. Create the application in AMS

    amc application create <app_folder>
    
  3. After the application is created successfully, launch a container from the dashboard

  4. Check the output of amc ls command and find the endpoint of the adb service exposed from the running container.

  5. Then connect the adb service from the local machine via

    adb connect <adb_service_endpoint>
    

Then it should be good to go.

Hi Gary,
Thanks for your all support here.

Best regards.

Alex.

Hi Gary.
Is there any way to create the session from the command line(terminal of the anbox cloud appliance instance) rather than from the dashboard?

Best regards.

Alex.

Yes, there is.

To Create a session from the command line,

  1. Create an auth token for the access to anbox stream gateway.

    anbox-cloud-appliance gateway account create <account_name>
    

    The above command would work for the scenario where Anbox Cloud appliance is deployed. A valid auth token will be returned as a result.

  2. Create a new session with the curl:

     TOKEN=<auth_token>
     curl -k -X "POST" \
        https://<DNS_name_of_Anbox_Cloud_Appliance>/1.0/sessions \
        -H "Authorization: macaroon root=$TOKEN" \
        -H "Content-Type: application/json" \
        -d '{"app": "<app_name>","joinable":true,"idle_time_min":5,"screen": 
        {"fps":60,"height":720,"width":1280}}'
    

    Please replace the <auth_token> and <app_name> as you need in the above command. A json-format based response will be returned. And you could check the status of the session with the following command. And the <session_id> can be retrieved from the response of the above command.

    TOKEN=<auth_token>
    curl -k -X "GET" \
       https://<DNS_name_of_Anbox_Cloud_Appliance>/1.0/sessions/<session_id> \
       -H "Authorization: macaroon root=$TOKEN"
    

You could also refer to the doc on how to access the stream gateway

BR
Gary

Great, Thanks Gary.
Let me try.

Best regards.

Alex.