Giter Site home page Giter Site logo

amazon-ivs-broadcast-android-sample's Introduction

Amazon IVS Broadcast Android SDK Sample App

This repository contains a sample app which use the IVS Broadcast Android SDK.

Setup

  1. Install and setup Android Studio
  2. Clone the repository to your local machine
  3. Open the project in Android Studio
  4. You can now build and run the sample projects.

License

This project is licensed under the MIT-0 License. See the LICENSE file.

amazon-ivs-broadcast-android-sample's People

Contributors

amazon-auto avatar bclymer avatar caleighatamazon avatar caleighm avatar dang-tommy avatar kvasilye avatar michaeljecmen avatar ryanecrist avatar wongvws avatar wongws avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amazon-ivs-broadcast-android-sample's Issues

Published video is mirrored when played using ivs player sdk

Have tried adding below lines,to make behaviour similar to ivs sdk,but is there any other way to prevent mirroring(movement of head towards left in broadcast device,shows as movement towards right in player sdk)?

ImagePreviewView preview =
((ImageDevice) device).getPreviewView(BroadcastConfiguration.AspectMode.FILL);
preview.setMirrored(false);

IVS's new preset configurations is not appearing in SDK

Hello,

I checked FAQ page for new presets. But i cannot find new preset configurations in SDK. For example; how can i setting 'Constrained bandwidth delivery' at mobile SDK.

IVS FAQ

Here SDK's configurations

public static final class Configuration {
        public static final BroadcastConfiguration STANDARD_PORTRAIT = new BroadcastConfiguration();
        public static final BroadcastConfiguration STANDARD_LANDSCAPE;
        public static final BroadcastConfiguration BASIC_LANDSCAPE;
        public static final BroadcastConfiguration BASIC_PORTRAIT;
        public static final BroadcastConfiguration GAMING_LANDSCAPE;
        public static final BroadcastConfiguration GAMING_PORTRAIT;

        public Configuration() {
        }

        static {
            STANDARD_LANDSCAPE = STANDARD_PORTRAIT.changing(($) -> {
                $.video.setSize((int)$.video.getSize().y, (int)$.video.getSize().x);
                return $;
            });
            BASIC_LANDSCAPE = BroadcastConfiguration.with(($) -> {
                $.video.setInitialBitrate(1200000);
                $.video.setMaxBitrate(1500000);
                $.video.setUseBFrames(false);
                $.video.setSize(new BroadcastConfiguration.Vec2(852.0F, 480.0F));
                return $;
            });
            BASIC_PORTRAIT = BroadcastConfiguration.with(($) -> {
                $.video.setInitialBitrate(1200000);
                $.video.setMaxBitrate(1500000);
                $.video.setUseBFrames(false);
                $.video.setSize(new BroadcastConfiguration.Vec2(480.0F, 852.0F));
                return $;
            });
            GAMING_LANDSCAPE = BroadcastConfiguration.with(($) -> {
                $.video.setInitialBitrate(2100000);
                $.video.setMaxBitrate(6000000);
                $.video.setMinBitrate(900000);
                $.video.setSize(new BroadcastConfiguration.Vec2(1280.0F, 720.0F));
                $.video.setTargetFramerate(30);
                $.audio.setBitrate(128000);
                $.mixer.slots = new BroadcastConfiguration.Mixer.Slot[]{Slot.with((slot) -> {
                    slot.setSize($.video.getSize());
                    slot.setAspect(AspectMode.FILL);
                    slot.setName("game");
                    slot.setPreferredAudioInput(DeviceType.SYSTEM_AUDIO);
                    slot.setPreferredVideoInput(DeviceType.SCREEN);
                    return slot;
                }), Slot.with((slot) -> {
                    slot.setSize(new BroadcastConfiguration.Vec2(200.0F, 150.0F));
                    slot.setPosition(new BroadcastConfiguration.Vec2($.video.getSize().x - 300.0F, $.video.getSize().y - 200.0F));
                    slot.setAspect(AspectMode.FILL);
                    slot.setPreferredAudioInput(DeviceType.MICROPHONE);
                    slot.setPreferredVideoInput(DeviceType.CAMERA);
                    slot.setzIndex(10);
                    slot.setName("camera");
                    return slot;
                })};
                return $;
            });
            GAMING_PORTRAIT = BroadcastConfiguration.with(($) -> {
                $.video.setInitialBitrate(2100000);
                $.video.setMaxBitrate(6000000);
                $.video.setMinBitrate(900000);
                $.video.setSize(new BroadcastConfiguration.Vec2(720.0F, 1280.0F));
                $.video.setTargetFramerate(30);
                $.audio.setBitrate(128000);
                $.mixer.slots = new BroadcastConfiguration.Mixer.Slot[]{Slot.with((slot) -> {
                    slot.setSize($.video.getSize());
                    slot.setAspect(AspectMode.FILL);
                    slot.setName("game");
                    slot.setPreferredAudioInput(DeviceType.SYSTEM_AUDIO);
                    slot.setPreferredVideoInput(DeviceType.SCREEN);
                    return slot;
                }), Slot.with((slot) -> {
                    slot.setSize(new BroadcastConfiguration.Vec2(200.0F, 150.0F));
                    slot.setPosition(new BroadcastConfiguration.Vec2($.video.getSize().x - 300.0F, $.video.getSize().y - 200.0F));
                    slot.setAspect(AspectMode.FILL);
                    slot.setPreferredAudioInput(DeviceType.MICROPHONE);
                    slot.setPreferredVideoInput(DeviceType.CAMERA);
                    slot.setzIndex(10);
                    slot.setName("camera");
                    return slot;
                })};
                return $;
            });
        }
    }

Duplicate class org.webrtc.AddIceObserver in flutter_webrtc and com.amazonaws:ivs-broadcast:1.9.0:stages@aar

I've encountered a problem with duplicate classes when using the flutter_webrtc and com.amazonaws:ivs-broadcast:1.9.0:stages@aar libraries together in my Flutter project.

In my pubspec.yaml I have:
flutter_webrtc: ^0.9.33

And in my build.gradle for Android, I have:
implementation('com.amazonaws:ivs-broadcast:1.9.0:stages@aar')

When I attempt to build, I encounter the following error:
Duplicate class org.webrtc.AddIceObserver found in modules jetified-android-104.5112.06-runtime (com.github.webrtc-sdk:android:104.5112.06) and jetified-ivs-broadcast-1.9-stages.0-stages-runtime (com.amazonaws:ivs-broadcast:1.9.0)

I've tried to exclude the org.webrtc module from ivs-broadcast library in build.gradle, but the error persists.
:implementation('com.amazonaws:ivs-broadcast:1.9.0:stages@aar'){
exclude group: 'org.webrtc', module: 'webrtc'
}

Could you please provide any guidance or potential solutions to address this issue?

How to support landscape mode

When switch to landscape, the video looks like the screenshot attached, how to make it fill screen? I already set the aspect to fill.
Screenshot_20230508-120723

Play in the background for more than 10 seconds, CameraSource log error "AmazonIVS: Camera error 3"

The Steps:
1.The connection is established and the push stream is successful
2.Back to the background for more than 10 seconds
then CameraSource will log error "AmazonIVS: Camera error 3"
At this point, go back to the front, you will find that audio stream will resume but preview screen stuck. onDeviceAdded() will be called back,if i call attachCameraDevice again,the screen will return to normal.But the audience still can't see it, it's just that the preview is not stuck.
I would like to know, how to resume video streaming at this point.
Thanks!

Question-Does SDK support broadcast two camera source at same time?

My case is the host maybe want to open both back and front camera, I tried to use Mixer to bind two cameras, but got error:

2023-08-07 15:25:34.857 12446-12817 AmazonIVS            E  Cannot attach camera device because another device is currently attached
2023-08-07 15:25:34.857 12446-12817 AmazonIVS            E  Failed to attach device 0

How to make the preview screen full screen

Hi,I have mobile phones with multiple resolutions. On 1080x1920, there will be black borders on the left and right when previewing, and on 1080x2340, there will be black borders on the top and bottom when previewing. I tried tweaking the parameters of BroadcastConfiguration Vec2, but it only seems to have an effect on the launched stream. TextureView has been set to full screen, I guess it is the surface output by the camera, which is not scaled and cropped proportionally. If there is a way to set the preview to be full screen please let me know, thanks.

App hangs on real device

Hi,
I'm currently investigating a problem that seems to have emerged when my phone upgraded to Android 14 (API 34).
In an API 34 Emulator, everything is working fine. On my phone (Samsung S22 - if that matters) however, the example app just hangs when I try to start a broadcast.

Logcat does not show any suspicious output, as far as I can see.

Is there anything I can provide or do to help debug the issue?

FWIW, I attached a logcat log that starts just before I press the "START" button and ends just after I manually kill the app: samsung-SM-S901B-Android-14_2023-12-15_131457.zip

Request for roadmap to implement Zoom feature

Hello,

We are currently using the IVS-Broadcast library for our project and we are wondering if it supports the ability to Zoom during broadcasts. If this feature is available, we would like to request a roadmap on how to implement it into our application.

Thank you.

Is there a way to generate stream key from the SDK?

Hi, this tool is amazing. Just checking your repository, it is not an issue, but I have a question:

It assumes you already have the channel and stream key. But is there a way to generate stream keys or the channel itself from the SDK?
or that can be achieved only with the web page where you create channels?

anyway to use beauty face filter feature

hi, I'm sorry that this isn't really an issue with your project but just my concern.
I reading up your sample project and your document, but I don't see any parts that can enable beauty face filter, I'm wondering is your sdk has any built-in api can handle that work? or can attached a third party library like faceunity to do that job.
I hope can receive your answer soon, please forgive me if I drop my my concern wrongly.
thanks.

UnsatisfiedLinkError

There is no such issue when I use version 1.7.3,
the issue occured after upgrade to 1.8.0

java.lang.UnsatisfiedLinkError: No implementation found for com.amazonaws.ivs.broadcast.Device$Descriptor[] com.amazonaws.ivs.broadcast.Device$Descriptor.listAvailableDevices(android.content.Context) (tried Java_com_amazonaws_ivs_broadcast_Device_00024Descriptor_listAvailableDevices and Java_com_amazonaws_ivs_broadcast_Device_00024Descriptor_listAvailableDevices__Landroid_content_Context_2)
                 	at com.amazonaws.ivs.broadcast.Device$Descriptor.listAvailableDevices(Native Method)
                 	at com.amazonaws.ivs.broadcast.Device$Descriptor.availableDevices(Device.java:114)
                 	at com.amazonaws.ivs.broadcast.Device$Descriptor.access$000(Device.java:30)
                 	at com.amazonaws.ivs.broadcast.Device.listAvailableDevices(Device.java:20)
                 	at com.amazonaws.ivs.broadcast.Session.listAvailableDevices(Session.java:54)

Camera / audio is still in use even after the stage is closed or leave

Hi,

i am using the demo app and its working fine only one issue we noticed during the testing, the camera / audio is till in use even after we leave the stage i am using the basic broadcast sample and then while testing our tester found even after we exit or leave the call the camera/audio is in access, the problem is in the sample (sample code) also. How we tested is that after leaving the stage and backpress and we navigate to out previous activity the we open camera or screen recorder and try to record a video the system showing we cant record voice as its used by our app so after destring the app completely from task bar we were able to record the video with sound, So please help to solve this issue.

on destroy we used the following codes

override fun onDestroy() {
      clearPreview()
      leaveStage()
      viewModel.release()
      super.onDestroy()
  }

clearPreview()

private fun clearPreview() {
      binding.participantListLayout.removeAllViews()
      binding.opponentView.removeAllViews()
      binding.userView.removeAllViews()
  }

leaveStage()

   private fun leaveStage() {
        viewModel.leaveStage()

    }

@dang-tommy Please give a help as we are at deadline of our release

Private Channels Question

For creating private channels can a single Playback Key be used to sign multiple channels or is the limitation 3 private streams at a time?

Unable to broadcast if amazon ivs broadcast only exist inside DFM module

Broadcast not working if library only implemented inside DFM (Dynamic Feature Delivery) module. It will works if base module implement it, and all SO files are inside Base APK.
Details:

Android broadcast SDK: 1.2.0
Gradle: 7.3
Android Gradle Plugin 7.0

Assume I have 2 modules, module A is application module and module B is Dynamic Feature Module.
Amazon Broadcast only implemented inside DFM module B, to help reduce our main APK size.

When starting broadcast, it show blank black screen with this repeated error:


022-01-17 16:33:23.662 16578-16578/com.traveloka.android.staging W/AmazonIVS: External cameras are not supported on this device, not listing USB devices
2022-01-17 16:33:23.663 16578-16578/com.traveloka.android.staging D/AmazonIVS: Using size 1280x720 (1,777778)
2022-01-17 16:33:23.663 16578-16578/com.traveloka.android.staging D/AmazonIVS: Using size 1920x1080 (1,777778)
2022-01-17 16:33:23.670 16578-29746/com.traveloka.android.staging E/AmazonIVS: FATAL: No opengl configurations: 
2022-01-17 16:33:23.685 16578-29746/com.traveloka.android.staging I/AmazonIVS: Surface=0x9d821a60 window=0xa7acd008
2022-01-17 16:33:23.709 16578-29746/com.traveloka.android.staging I/AmazonIVS: Surface=0x9767c180 window=0xa7e63008 display=0x1 config=0x2
2022-01-17 16:33:23.752 16578-16578/com.traveloka.android.staging I/AmazonIVS: create http client okhttp
2022-01-17 16:33:23.759 16578-29746/com.traveloka.android.staging I/AmazonIVS: Surface=0xa0801f80 window=0xa7ad5008
2022-01-17 16:33:23.782 16578-29750/com.traveloka.android.staging D/AmazonIVS: Using fps range 5->30
2022-01-17 16:33:23.817 16578-16578/com.traveloka.android.staging D/AmazonIVS: Using size 1280x720 (1,777778)
2022-01-17 16:33:23.818 16578-16578/com.traveloka.android.staging D/AmazonIVS: Using size 1920x1080 (1,777778)
2022-01-17 16:33:23.819 16578-29746/com.traveloka.android.staging E/AmazonIVS: Shader compilation failed
2022-01-17 16:33:23.820 16578-29746/com.traveloka.android.staging E/AmazonIVS: Shader compilation failed
2022-01-17 16:33:23.821 16578-29746/com.traveloka.android.staging E/AmazonIVS: 337 glGetError=502
2022-01-17 16:33:24.124 16578-29746/com.traveloka.android.staging E/AmazonIVS: Shader compilation failed
2022-01-17 16:33:24.125 16578-29746/com.traveloka.android.staging E/AmazonIVS: Shader compilation failed
2022-01-17 16:33:24.133 16578-29746/com.traveloka.android.staging E/AmazonIVS: 337 glGetError=502
2022-01-17 16:33:24.156 16578-29746/com.traveloka.android.staging I/AmazonIVS: Surface=0x9767e520 window=0xa7b1a808
2022-01-17 16:33:24.159 16578-29746/com.traveloka.android.staging E/AmazonIVS: Shader compilation failed
2022-01-17 16:33:24.160 16578-29746/com.traveloka.android.staging E/AmazonIVS: Shader compilation failed
2022-01-17 16:33:24.163 16578-29746/com.traveloka.android.staging E/AmazonIVS: 337 glGetError=502
2022-01-17 16:33:24.179 16578-29746/com.traveloka.android.staging E/AmazonIVS: Shader compilation failed
2022-01-17 16:33:24.179 16578-29746/com.traveloka.android.staging E/AmazonIVS: Shader compilation failed
2022-01-17 16:33:24.185 16578-29746/com.traveloka.android.staging E/AmazonIVS: 337 glGetError=502
2022-01-17 16:33:24.198 16578-29746/com.traveloka.android.staging E/AmazonIVS: Shader compilation failed
2022-01-17 16:33:24.199 16578-29746/com.traveloka.android.staging E/AmazonIVS: Shader compilation failed
2022-01-17 16:33:24.219 16578-29746/com.traveloka.android.staging E/AmazonIVS: 337 glGetError=502
2022-01-17 16:33:24.257 16578-29746/com.traveloka.android.staging E/AmazonIVS: Shader compilation failed
2022-01-17 16:33:24.258 16578-29746/com.traveloka.android.staging E/AmazonIVS: Shader compilation failed
2022-01-17 16:33:24.262 16578-29746/com.traveloka.android.staging E/AmazonIVS: 337 glGetError=502

However, if we add amazon broadcast SDK dependencies to our application module the issue is gone. This is the logcat from it:

2022-01-17 16:30:57.253 31672-31672/com.traveloka.android.staging D/AmazonIVS: Found library broadcastcore
2022-01-17 16:30:57.256 31672-31672/com.traveloka.android.staging W/AmazonIVS: External cameras are not supported on this device, not listing USB devices
2022-01-17 16:30:57.267 31672-31672/com.traveloka.android.staging D/AmazonIVS: Using size 1280x720 (1.777778)
2022-01-17 16:30:57.268 31672-31672/com.traveloka.android.staging D/AmazonIVS: Using size 1280x720 (1.777778)
2022-01-17 16:30:57.282 31672-32010/com.traveloka.android.staging E/AmazonIVS: FATAL: No opengl configurations: 
2022-01-17 16:30:57.294 31672-32010/com.traveloka.android.staging I/AmazonIVS: Surface=0x77c8c460 window=0x6b7ff008
2022-01-17 16:30:57.368 31672-32010/com.traveloka.android.staging I/AmazonIVS: Surface=0x77c8c1f0 window=0x6ad5c008 display=0x1 config=0x2
2022-01-17 16:30:57.441 31672-31672/com.traveloka.android.staging I/AmazonIVS: create http client okhttp
2022-01-17 16:30:57.473 31672-32010/com.traveloka.android.staging I/AmazonIVS: Surface=0x775d3dd0 window=0x6b7ff808
2022-01-17 16:30:57.531 31672-32005/com.traveloka.android.staging D/AmazonIVS: Using fps range 5->30
2022-01-17 16:30:57.559 31672-31672/com.traveloka.android.staging D/AmazonIVS: Using size 1280x720 (1.777778)
2022-01-17 16:30:57.561 31672-31672/com.traveloka.android.staging D/AmazonIVS: Using size 1280x720 (1.777778)
2022-01-17 16:30:57.866 31672-32010/com.traveloka.android.staging I/AmazonIVS: Surface=0x6b6f2d50 window=0x6b5ff808

In this case, all SO files and SDK from amazon broadcast are move to base apk, and probably because of that this log is showing up D/AmazonIVS: Found library broadcastcore.

However put amazon broadcast dependencies to our base APK will adding 2 MB to our download and install size.

Do you have some idea if it issue from amazon broadcast SDK(maybe not supporting DFM yet) or something I can do to make it works with only DFM module implementation?

Let me know if you need additional information.
Thank you in advance

SDK crashed with one of our users

Fatal Exception: com.amazonaws.ivs.broadcast.BroadcastException
[ERR] [SurfaceSource] ERROR (0): Failed to get preview view
com.amazonaws.ivs.broadcast.SurfaceSource.getPreviewView (SurfaceSource.java:65)
com.xxx.ui.broadcasting.BroadcastingViewModel.displayCameraOutput (BroadcastingViewModel.kt:393)
com.xxx.ui.broadcasting.BroadcastingViewModel.createSession$lambda-5 (BroadcastingViewModel.kt:190)

Why doesn't return preview view?

Preview not appearing

I have integrated the same code into my project. But it is showing blank preview. Please help.

Mobile Network Connection Issues

We're implementing the broadcast SDK for our Android application and noticing an issue for certain Android devices connected to a Stage on mobile networks. The network strength degrades almost instantly and the user is presented with a network outage. Here is an example of the outage UI on an Android device connected to mobile data.

image

Currently, the SDK is being implemented in parallel to a foreground service to allow users to keep listening while the app is pushed to the foreground. Removing the foreground service did not seem to relieve the network issues on mobile.

To be clear, this does NOT happen while connected to WIFI.

Current build implementation
// IVS broadcast implementation 'com.amazonaws:ivs-broadcast:1.16.0:stages@aar'

All mobile participants are given SUBSCRIBE capabilities only with AUDIO_ONLY

`@NonNull
@Override
public List<LocalStageStream> stageStreamsToPublishForParticipant(@NonNull Stage stage, @NonNull ParticipantInfo participantInfo) {
    return new ArrayList<>();
}

@Override
public boolean shouldPublishFromParticipant(@NonNull Stage stage, @NonNull ParticipantInfo participantInfo) {
    return false;
}

@Override
public Stage.SubscribeType shouldSubscribeToParticipant(@NonNull Stage stage, @NonNull ParticipantInfo participantInfo) {
    return Stage.SubscribeType.AUDIO_ONLY;
}`

If I change the SubscribeType to NONE, the network issue will not reproduce, but the app doesn't allow the user to hear the broadcast.

We're NOT currently opted into Simulcast

Thanks for any help with this!
Jon

Watching/Joining stream by other user

Is this sample capable of allowing a user to join stream created by someone else? If no, Kindly help me with this. How I can achieve it. I have all the authorizations tuff enabled for my channel.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.