parent
adccd4cfb0
commit
766be308ea
@ -0,0 +1 @@
|
||||
/build
|
@ -1,10 +1,11 @@
|
||||
package net.ossrs.yasea.rtmp;
|
||||
package com.github.faucamp.simplertmp;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Some helper utilities for SHA256, mostly (used during handshake)
|
@ -1,9 +1,9 @@
|
||||
package net.ossrs.yasea.rtmp;
|
||||
package com.github.faucamp.simplertmp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import net.ossrs.yasea.rtmp.io.RtmpConnection;
|
||||
import com.github.faucamp.simplertmp.io.RtmpConnection;
|
||||
|
||||
/**
|
||||
* Srs implementation of an RTMP publisher
|
@ -1,4 +1,4 @@
|
||||
package net.ossrs.yasea.rtmp;
|
||||
package com.github.faucamp.simplertmp;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
@ -1,4 +1,4 @@
|
||||
package net.ossrs.yasea.rtmp;
|
||||
package com.github.faucamp.simplertmp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
@ -1,4 +1,4 @@
|
||||
package net.ossrs.yasea.rtmp;
|
||||
package com.github.faucamp.simplertmp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
@ -1,4 +1,4 @@
|
||||
package net.ossrs.yasea.rtmp.amf;
|
||||
package com.github.faucamp.simplertmp.amf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
@ -1,4 +1,4 @@
|
||||
package net.ossrs.yasea.rtmp.amf;
|
||||
package com.github.faucamp.simplertmp.amf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
@ -1,4 +1,4 @@
|
||||
package net.ossrs.yasea.rtmp.amf;
|
||||
package com.github.faucamp.simplertmp.amf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
@ -1,11 +1,11 @@
|
||||
package net.ossrs.yasea.rtmp.amf;
|
||||
package com.github.faucamp.simplertmp.amf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import net.ossrs.yasea.rtmp.Util;
|
||||
import com.github.faucamp.simplertmp.Util;
|
||||
|
||||
/**
|
||||
* AMF map; that is, an "object"-like structure of key/value pairs, but with
|
@ -1,10 +1,10 @@
|
||||
package net.ossrs.yasea.rtmp.amf;
|
||||
package com.github.faucamp.simplertmp.amf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.ossrs.yasea.rtmp.Util;
|
||||
import com.github.faucamp.simplertmp.Util;
|
||||
|
||||
/**
|
||||
* AMF0 Number data type
|
@ -1,4 +1,4 @@
|
||||
package net.ossrs.yasea.rtmp.amf;
|
||||
package com.github.faucamp.simplertmp.amf;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
@ -1,4 +1,4 @@
|
||||
package net.ossrs.yasea.rtmp.amf;
|
||||
package com.github.faucamp.simplertmp.amf;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
@ -1,12 +1,12 @@
|
||||
package net.ossrs.yasea.rtmp.io;
|
||||
package com.github.faucamp.simplertmp.io;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import net.ossrs.yasea.rtmp.Util;
|
||||
import net.ossrs.yasea.rtmp.packets.RtmpHeader;
|
||||
import com.github.faucamp.simplertmp.Util;
|
||||
import com.github.faucamp.simplertmp.packets.RtmpHeader;
|
||||
|
||||
/**
|
||||
* Chunk stream channel information
|
@ -1,22 +1,22 @@
|
||||
package net.ossrs.yasea.rtmp.io;
|
||||
package com.github.faucamp.simplertmp.io;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import net.ossrs.yasea.rtmp.packets.Abort;
|
||||
import net.ossrs.yasea.rtmp.packets.Audio;
|
||||
import net.ossrs.yasea.rtmp.packets.Command;
|
||||
import net.ossrs.yasea.rtmp.packets.Data;
|
||||
import net.ossrs.yasea.rtmp.packets.RtmpHeader;
|
||||
import net.ossrs.yasea.rtmp.packets.RtmpPacket;
|
||||
import net.ossrs.yasea.rtmp.packets.SetChunkSize;
|
||||
import net.ossrs.yasea.rtmp.packets.SetPeerBandwidth;
|
||||
import net.ossrs.yasea.rtmp.packets.UserControl;
|
||||
import net.ossrs.yasea.rtmp.packets.Video;
|
||||
import net.ossrs.yasea.rtmp.packets.WindowAckSize;
|
||||
import net.ossrs.yasea.rtmp.packets.Acknowledgement;
|
||||
import com.github.faucamp.simplertmp.packets.Abort;
|
||||
import com.github.faucamp.simplertmp.packets.Audio;
|
||||
import com.github.faucamp.simplertmp.packets.Command;
|
||||
import com.github.faucamp.simplertmp.packets.Data;
|
||||
import com.github.faucamp.simplertmp.packets.RtmpHeader;
|
||||
import com.github.faucamp.simplertmp.packets.RtmpPacket;
|
||||
import com.github.faucamp.simplertmp.packets.SetChunkSize;
|
||||
import com.github.faucamp.simplertmp.packets.SetPeerBandwidth;
|
||||
import com.github.faucamp.simplertmp.packets.UserControl;
|
||||
import com.github.faucamp.simplertmp.packets.Video;
|
||||
import com.github.faucamp.simplertmp.packets.WindowAckSize;
|
||||
import com.github.faucamp.simplertmp.packets.Acknowledgement;
|
||||
|
||||
/**
|
||||
* @author francois
|
@ -1,10 +1,10 @@
|
||||
package net.ossrs.yasea.rtmp.io;
|
||||
package com.github.faucamp.simplertmp.io;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.ossrs.yasea.rtmp.packets.RtmpPacket;
|
||||
import com.github.faucamp.simplertmp.packets.RtmpPacket;
|
||||
|
||||
/**
|
||||
*
|
@ -1,6 +1,6 @@
|
||||
package net.ossrs.yasea.rtmp.io;
|
||||
package com.github.faucamp.simplertmp.io;
|
||||
|
||||
import net.ossrs.yasea.rtmp.packets.RtmpPacket;
|
||||
import com.github.faucamp.simplertmp.packets.RtmpPacket;
|
||||
|
||||
/**
|
||||
* Thrown by RTMP read thread when an Acknowledgement packet needs to be sent
|
@ -1,11 +1,11 @@
|
||||
package net.ossrs.yasea.rtmp.packets;
|
||||
package com.github.faucamp.simplertmp.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.ossrs.yasea.rtmp.Util;
|
||||
import net.ossrs.yasea.rtmp.io.ChunkStreamInfo;
|
||||
import com.github.faucamp.simplertmp.Util;
|
||||
import com.github.faucamp.simplertmp.io.ChunkStreamInfo;
|
||||
|
||||
/**
|
||||
* A "Abort" RTMP control message, received on chunk stream ID 2 (control channel)
|
@ -1,11 +1,11 @@
|
||||
package net.ossrs.yasea.rtmp.packets;
|
||||
package com.github.faucamp.simplertmp.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.ossrs.yasea.rtmp.Util;
|
||||
import net.ossrs.yasea.rtmp.io.ChunkStreamInfo;
|
||||
import com.github.faucamp.simplertmp.Util;
|
||||
import com.github.faucamp.simplertmp.io.ChunkStreamInfo;
|
||||
|
||||
/**
|
||||
* (Window) Acknowledgement
|
@ -1,6 +1,6 @@
|
||||
package net.ossrs.yasea.rtmp.packets;
|
||||
package com.github.faucamp.simplertmp.packets;
|
||||
|
||||
import net.ossrs.yasea.rtmp.io.ChunkStreamInfo;
|
||||
import com.github.faucamp.simplertmp.io.ChunkStreamInfo;
|
||||
|
||||
/**
|
||||
* Audio data packet
|
@ -1,12 +1,12 @@
|
||||
package net.ossrs.yasea.rtmp.packets;
|
||||
package com.github.faucamp.simplertmp.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.ossrs.yasea.rtmp.amf.AmfNumber;
|
||||
import net.ossrs.yasea.rtmp.amf.AmfString;
|
||||
import net.ossrs.yasea.rtmp.io.ChunkStreamInfo;
|
||||
import com.github.faucamp.simplertmp.amf.AmfNumber;
|
||||
import com.github.faucamp.simplertmp.amf.AmfString;
|
||||
import com.github.faucamp.simplertmp.io.ChunkStreamInfo;
|
||||
|
||||
/**
|
||||
* Encapsulates an command/"invoke" RTMP packet
|
@ -1,10 +1,10 @@
|
||||
package net.ossrs.yasea.rtmp.packets;
|
||||
package com.github.faucamp.simplertmp.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.ossrs.yasea.rtmp.Util;
|
||||
import com.github.faucamp.simplertmp.Util;
|
||||
|
||||
/**
|
||||
* Content (audio/video) data packet base
|
@ -1,11 +1,11 @@
|
||||
package net.ossrs.yasea.rtmp.packets;
|
||||
package com.github.faucamp.simplertmp.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.ossrs.yasea.rtmp.amf.AmfString;
|
||||
import net.ossrs.yasea.rtmp.io.ChunkStreamInfo;
|
||||
import com.github.faucamp.simplertmp.amf.AmfString;
|
||||
import com.github.faucamp.simplertmp.io.ChunkStreamInfo;
|
||||
|
||||
/**
|
||||
* AMF Data packet
|
@ -1,11 +1,11 @@
|
||||
package net.ossrs.yasea.rtmp.packets;
|
||||
package com.github.faucamp.simplertmp.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.ossrs.yasea.rtmp.io.ChunkStreamInfo;
|
||||
import com.github.faucamp.simplertmp.io.ChunkStreamInfo;
|
||||
|
||||
/**
|
||||
*
|
@ -1,11 +1,11 @@
|
||||
package net.ossrs.yasea.rtmp.packets;
|
||||
package com.github.faucamp.simplertmp.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.ossrs.yasea.rtmp.Util;
|
||||
import net.ossrs.yasea.rtmp.io.ChunkStreamInfo;
|
||||
import com.github.faucamp.simplertmp.Util;
|
||||
import com.github.faucamp.simplertmp.io.ChunkStreamInfo;
|
||||
|
||||
/**
|
||||
* A "Set chunk size" RTMP message, received on chunk stream ID 2 (control channel)
|
@ -1,6 +1,6 @@
|
||||
package net.ossrs.yasea.rtmp.packets;
|
||||
package com.github.faucamp.simplertmp.packets;
|
||||
|
||||
import net.ossrs.yasea.rtmp.io.ChunkStreamInfo;
|
||||
import com.github.faucamp.simplertmp.io.ChunkStreamInfo;
|
||||
|
||||
/**
|
||||
* Video data packet
|
@ -1,11 +1,11 @@
|
||||
package net.ossrs.yasea.rtmp.packets;
|
||||
package com.github.faucamp.simplertmp.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.ossrs.yasea.rtmp.Util;
|
||||
import net.ossrs.yasea.rtmp.io.ChunkStreamInfo;
|
||||
import com.github.faucamp.simplertmp.Util;
|
||||
import com.github.faucamp.simplertmp.io.ChunkStreamInfo;
|
||||
|
||||
/**
|
||||
* Window Acknowledgement Size
|
@ -1,377 +0,0 @@
|
||||
package net.ossrs.yasea;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.ossrs.yasea.rtmp.RtmpHandler;
|
||||
|
||||
import com.seu.magicfilter.utils.MagicFilterType;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpListener,
|
||||
SrsRecordHandler.SrsRecordListener, SrsNetworkHandler.SrsNetworkListener {
|
||||
|
||||
private static final String TAG = "Yasea";
|
||||
|
||||
Button btnPublish = null;
|
||||
Button btnSwitchCamera = null;
|
||||
Button btnRecord = null;
|
||||
Button btnSwitchEncoder = null;
|
||||
|
||||
private SharedPreferences sp;
|
||||
private String rtmpUrl = "rtmp://ossrs.net/" + getRandomAlphaString(3) + '/' + getRandomAlphaDigitString(5);
|
||||
private String recPath = Environment.getExternalStorageDirectory().getPath() + "/test.mp4";
|
||||
|
||||
private SrsPublisher mPublisher;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// response screen rotation event
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
|
||||
|
||||
// restore data.
|
||||
sp = getSharedPreferences("Yasea", MODE_PRIVATE);
|
||||
rtmpUrl = sp.getString("rtmpUrl", rtmpUrl);
|
||||
|
||||
// initialize url.
|
||||
final EditText efu = (EditText) findViewById(R.id.url);
|
||||
efu.setText(rtmpUrl);
|
||||
|
||||
btnPublish = (Button) findViewById(R.id.publish);
|
||||
btnSwitchCamera = (Button) findViewById(R.id.swCam);
|
||||
btnRecord = (Button) findViewById(R.id.record);
|
||||
btnSwitchEncoder = (Button) findViewById(R.id.swEnc);
|
||||
|
||||
mPublisher = new SrsPublisher((SrsCameraView) findViewById(R.id.glsurfaceview_camera));
|
||||
mPublisher.setRtmpHandler(new RtmpHandler(this));
|
||||
mPublisher.setRecordHandler(new SrsRecordHandler(this));
|
||||
mPublisher.setNetworkHandler(new SrsNetworkHandler(this));
|
||||
mPublisher.setPreviewResolution(640, 480);
|
||||
|
||||
btnPublish.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (btnPublish.getText().toString().contentEquals("publish")) {
|
||||
rtmpUrl = efu.getText().toString();
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putString("rtmpUrl", rtmpUrl);
|
||||
editor.apply();
|
||||
|
||||
mPublisher.setOutputResolution(720, 1280);
|
||||
mPublisher.setVideoHDMode();
|
||||
mPublisher.startPublish(rtmpUrl);
|
||||
|
||||
if (btnSwitchEncoder.getText().toString().contentEquals("soft encoder")) {
|
||||
Toast.makeText(getApplicationContext(), "Use hard encoder", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), "Use soft encoder", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
btnPublish.setText("stop");
|
||||
btnSwitchEncoder.setEnabled(false);
|
||||
} else if (btnPublish.getText().toString().contentEquals("stop")) {
|
||||
mPublisher.stopPublish();
|
||||
mPublisher.stopRecord();
|
||||
btnPublish.setText("publish");
|
||||
btnRecord.setText("record");
|
||||
btnSwitchEncoder.setEnabled(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnSwitchCamera.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (Camera.getNumberOfCameras() > 0) {
|
||||
mPublisher.switchCameraFace((mPublisher.getCamraId() + 1) % Camera.getNumberOfCameras());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnRecord.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (btnRecord.getText().toString().contentEquals("record")) {
|
||||
mPublisher.startRecord(recPath);
|
||||
btnRecord.setText("pause");
|
||||
} else if (btnRecord.getText().toString().contentEquals("pause")) {
|
||||
mPublisher.pauseRecord();
|
||||
btnRecord.setText("resume");
|
||||
} else if (btnRecord.getText().toString().contentEquals("resume")) {
|
||||
mPublisher.resumeRecord();
|
||||
btnRecord.setText("pause");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btnSwitchEncoder.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (btnSwitchEncoder.getText().toString().contentEquals("soft encoder")) {
|
||||
mPublisher.swithToSoftEncoder();
|
||||
btnSwitchEncoder.setText("hard encoder");
|
||||
} else if (btnSwitchEncoder.getText().toString().contentEquals("hard encoder")) {
|
||||
mPublisher.swithToHardEncoder();
|
||||
btnSwitchEncoder.setText("soft encoder");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable ex) {
|
||||
final String msg = ex.getMessage();
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
|
||||
mPublisher.stopPublish();
|
||||
mPublisher.stopRecord();
|
||||
btnPublish.setText("publish");
|
||||
btnRecord.setText("record");
|
||||
btnSwitchEncoder.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
} else {
|
||||
switch (id) {
|
||||
case R.id.cool_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.COOL);
|
||||
break;
|
||||
case R.id.beauty_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.BEAUTY);
|
||||
break;
|
||||
case R.id.early_bird_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.EARLYBIRD);
|
||||
break;
|
||||
case R.id.evergreen_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.EVERGREEN);
|
||||
break;
|
||||
case R.id.n1977_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.N1977);
|
||||
break;
|
||||
case R.id.nostalgia_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.NOSTALGIA);
|
||||
break;
|
||||
case R.id.romance_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.ROMANCE);
|
||||
break;
|
||||
case R.id.sunrise_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.SUNRISE);
|
||||
break;
|
||||
case R.id.sunset_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.SUNSET);
|
||||
break;
|
||||
case R.id.tender_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.TENDER);
|
||||
break;
|
||||
case R.id.toast_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.TOASTER2);
|
||||
break;
|
||||
case R.id.valencia_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.VALENCIA);
|
||||
break;
|
||||
case R.id.walden_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.WALDEN);
|
||||
break;
|
||||
case R.id.warm_filter:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.WARM);
|
||||
break;
|
||||
case R.id.original_filter:
|
||||
default:
|
||||
mPublisher.switchCameraFilter(MagicFilterType.NONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
setTitle(item.getTitle());
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
final Button btn = (Button) findViewById(R.id.publish);
|
||||
btn.setEnabled(true);
|
||||
mPublisher.resumeRecord();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mPublisher.pauseRecord();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mPublisher.stopPublish();
|
||||
mPublisher.stopRecord();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
mPublisher.setPreviewRotation(90);
|
||||
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
mPublisher.setPreviewRotation(0);
|
||||
}
|
||||
mPublisher.stopEncode();
|
||||
mPublisher.stopRecord();
|
||||
btnRecord.setText("record");
|
||||
mPublisher.setScreenOrientation(newConfig.orientation);
|
||||
if (btnPublish.getText().toString().contentEquals("stop")) {
|
||||
mPublisher.startEncode();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getRandomAlphaString(int length) {
|
||||
String base = "abcdefghijklmnopqrstuvwxyz";
|
||||
Random random = new Random();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < length; i++) {
|
||||
int number = random.nextInt(base.length());
|
||||
sb.append(base.charAt(number));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static String getRandomAlphaDigitString(int length) {
|
||||
String base = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
Random random = new Random();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < length; i++) {
|
||||
int number = random.nextInt(base.length());
|
||||
sb.append(base.charAt(number));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// Implementation of SrsRtmpListener.
|
||||
|
||||
@Override
|
||||
public void onRtmpConnecting(String msg) {
|
||||
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRtmpConnected(String msg) {
|
||||
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRtmpVideoStreaming() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRtmpAudioStreaming() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRtmpStopped() {
|
||||
Toast.makeText(getApplicationContext(), "Stopped", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRtmpDisconnected() {
|
||||
Toast.makeText(getApplicationContext(), "Disconnected", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRtmpVideoFpsChanged(double fps) {
|
||||
Log.i(TAG, String.format("Output Fps: %f", fps));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRtmpVideoBitrateChanged(double bitrate) {
|
||||
int rate = (int) bitrate;
|
||||
if (rate / 1000 > 0) {
|
||||
Log.i(TAG, String.format("Video bitrate: %f kbps", bitrate / 1000));
|
||||
} else {
|
||||
Log.i(TAG, String.format("Video bitrate: %d bps", rate));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRtmpAudioBitrateChanged(double bitrate) {
|
||||
int rate = (int) bitrate;
|
||||
if (rate / 1000 > 0) {
|
||||
Log.i(TAG, String.format("Audio bitrate: %f kbps", bitrate / 1000));
|
||||
} else {
|
||||
Log.i(TAG, String.format("Audio bitrate: %d bps", rate));
|
||||
}
|
||||
}
|
||||
|
||||
// Implementation of SrsRecordHandler.
|
||||
|
||||
@Override
|
||||
public void onRecordPause() {
|
||||
Toast.makeText(getApplicationContext(), "Record paused", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecordResume() {
|
||||
Toast.makeText(getApplicationContext(), "Record resumed", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecordStarted(String msg) {
|
||||
Toast.makeText(getApplicationContext(), "Recording file: " + msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecordFinished(String msg) {
|
||||
Toast.makeText(getApplicationContext(), "MP4 file saved: " + msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
// Implementation of SrsNetworkHandler.
|
||||
|
||||
@Override
|
||||
public void onNetworkWeak() {
|
||||
Toast.makeText(getApplicationContext(), "Network weak", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetworkResume() {
|
||||
Toast.makeText(getApplicationContext(), "Network resume", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
Loading…
Reference in New Issue