Skip to content

Commit

Permalink
It works!
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkucera committed Dec 20, 2015
1 parent 365749f commit a308f70
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.danman.zidostreamer.zidostreamer">
package="eu.danman.zidostreamer.zidostreamer"
android:sharedUserId="android.uid.system">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
package eu.danman.zidostreamer.zidostreamer;

import android.app.Activity;
import android.content.Intent;
import android.os.StrictMode;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

import com.mstar.android.tv.TvCommonManager;
import com.mstar.android.tvapi.common.TvManager;
import com.mstar.android.tvapi.common.exception.TvCommonException;
import com.mstar.android.tvapi.common.vo.TvOsType;


public class MainActivity extends ActionBarActivity {


SurfaceView surfaceView = null;
SurfaceHolder mSurfaceHolder = null;
SurfaceHolder.Callback callback = null;



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_main);
setContentView(R.layout.activity_main);

// StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();

// StrictMode.setThreadPolicy(policy);


surfaceView = (SurfaceView) this.findViewById(R.id.surfaceView);


// showHdmiOnSurfaceView();

Intent service = new Intent(this, StreamService.class);
startService(service);

Expand All @@ -35,6 +51,7 @@ protected void onCreate(Bundle savedInstanceState) {

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
Expand All @@ -56,4 +73,84 @@ public boolean onOptionsItemSelected(MenuItem item) {

return super.onOptionsItemSelected(item);
}


public static void changeInputSource(TvOsType.EnumInputSource eis)
{

TvCommonManager commonService = TvCommonManager.getInstance();
if (commonService != null)
{
TvOsType.EnumInputSource currentSource = commonService.getCurrentInputSource();
if (currentSource != null)
{
if (currentSource.equals(eis))
{
return;
}

commonService.setInputSource(eis);
}

}

}


public static boolean isHDMIinput()
{
boolean bRet = false;
try
{
changeInputSource(TvOsType.EnumInputSource.E_INPUT_SOURCE_HDMI);
bRet = TvManager.getInstance().getPlayerManager().isSignalStable();
} catch (TvCommonException e)
{
e.printStackTrace();
}
return bRet;
}

private void showHdmiOnSurfaceView()
{
mSurfaceHolder = surfaceView.getHolder();
callback = new android.view.SurfaceHolder.Callback()
{

@Override
public void surfaceDestroyed(SurfaceHolder holder)
{
}

@Override
public void surfaceCreated(SurfaceHolder holder)
{

try
{
if (holder == null || holder.getSurface() == null || holder.getSurface().isValid() == false)
{
return;
}
if (TvManager.getInstance() != null)
{
TvManager.getInstance().getPlayerManager().setDisplay(mSurfaceHolder);
}
} catch (TvCommonException e)
{
e.printStackTrace();
}
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
{
}
};
mSurfaceHolder.addCallback((android.view.SurfaceHolder.Callback) callback);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
import android.content.ContextWrapper;
import android.content.Intent;
import android.os.IBinder;
import android.os.SystemClock;
import android.system.ErrnoException;
import android.util.Log;

import com.mstar.android.tv.TvCommonManager;
import com.mstar.android.tvapi.common.PictureManager;
import com.mstar.android.tvapi.common.TvManager;
import com.mstar.android.tvapi.common.exception.TvCommonException;
import com.mstar.android.tvapi.common.vo.EnumScalerWindow;
import com.mstar.android.tvapi.common.vo.TvOsType;
import com.mstar.android.tvapi.common.vo.VideoWindowType;
import com.mstar.hdmirecorder.HdmiRecorder;

import java.io.File;
Expand Down Expand Up @@ -57,10 +65,48 @@ public StreamService() {

}

public static void changeInputSource(TvOsType.EnumInputSource eis)
{

TvCommonManager commonService = TvCommonManager.getInstance();
if (commonService != null)
{
TvOsType.EnumInputSource currentSource = commonService.getCurrentInputSource();
if (currentSource != null)
{
if (currentSource.equals(eis))
{
return;
}

commonService.setInputSource(eis);
}

}

}

public static boolean enableHDMI()
{
boolean bRet = false;
try
{
changeInputSource(TvOsType.EnumInputSource.E_INPUT_SOURCE_HDMI);
bRet = TvManager.getInstance().getPlayerManager().isSignalStable();
} catch (TvCommonException e)
{
e.printStackTrace();
}
return bRet;
}


@Override
public int onStartCommand(Intent intent, int flags, int startId) {
//TODO do something useful
//TODO do something


enableHDMI();



Expand Down
18 changes: 13 additions & 5 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
android:layout_height="match_parent"
tools:context=".MainActivity">

<SurfaceView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/surfaceView"
android:layout_alignTop="@+id/textView"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />

<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:id="@+id/textView" />

</RelativeLayout>
Binary file modified signed.apk
Binary file not shown.

0 comments on commit a308f70

Please sign in to comment.