cine-io / cineio-broadcast-android

The cine.io Android Broadcast SDK
https://www.cine.io/products/broadcast
MIT License
52 stars 32 forks source link

BroadCastConfig sets undefined height/width as 0 #5

Closed lgorse closed 9 years ago

lgorse commented 9 years ago

The current broadcast configuration breaks if the user does not input a resolution (setWidth/setHeight).

This is because un-instantiated ints such as:

public class BroadcastConfig {
    private int width;
    private int height;

return 0 rather than null.

Check out this test:

public class MainActivity extends ActionBarActivity {
    private int testnum;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.i("TEST A NUM", String.valueOf(testnum));
    }
}

This causes an error in BroadcastActivity when the activity tries to get the width and height as extras with default -1:

  if (extras != null) {
            outputString = extras.getString("PUBLISH_URL");
            width = extras.getInt("WIDTH", -1);
            height = extras.getInt("HEIGHT", -1);
            orientation = extras.getString("ORIENTATION");
            this.requestedCamera = extras.getString("CAMERA");

because the value never reaches default of -1, since default of un-instantiated int is 0.

I'll set up a fix and send you a PR.

trshafer commented 9 years ago

Resolved by #6.