|
|
@ -1,13 +1,10 @@ |
|
|
|
package com.frank.ffmpeg.activity; |
|
|
|
package com.frank.ffmpeg.activity; |
|
|
|
|
|
|
|
|
|
|
|
import android.support.v7.app.AppCompatActivity; |
|
|
|
|
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.text.TextUtils; |
|
|
|
import android.text.TextUtils; |
|
|
|
import android.util.Log; |
|
|
|
import android.util.Log; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.Button; |
|
|
|
|
|
|
|
import android.widget.EditText; |
|
|
|
import android.widget.EditText; |
|
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.frank.ffmpeg.Pusher; |
|
|
|
import com.frank.ffmpeg.Pusher; |
|
|
|
import com.frank.ffmpeg.R; |
|
|
|
import com.frank.ffmpeg.R; |
|
|
@ -18,31 +15,38 @@ import java.io.File; |
|
|
|
* 使用ffmpeg推流直播 |
|
|
|
* 使用ffmpeg推流直播 |
|
|
|
* Created by frank on 2018/2/2. |
|
|
|
* Created by frank on 2018/2/2. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class PushActivity extends AppCompatActivity { |
|
|
|
public class PushActivity extends BaseActivity { |
|
|
|
|
|
|
|
|
|
|
|
private static final String TAG = PushActivity.class.getSimpleName(); |
|
|
|
private static final String TAG = PushActivity.class.getSimpleName(); |
|
|
|
private static final String FILE_PATH = "storage/emulated/0/hello.flv"; |
|
|
|
private static final String FILE_PATH = "storage/emulated/0/hello.flv"; |
|
|
|
private static final String LIVE_URL = "rtmp://192.168.1.104/live/stream"; |
|
|
|
private static final String LIVE_URL = "rtmp://192.168.1.104/live/stream"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private EditText edit_file_path; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private EditText edit_live_url; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
int getLayoutId() { |
|
|
|
|
|
|
|
return R.layout.activity_push; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
setContentView(R.layout.activity_push); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initView(); |
|
|
|
initView(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initView() { |
|
|
|
private void initView() { |
|
|
|
final EditText edit_file_path = (EditText) findViewById(R.id.edit_file_path); |
|
|
|
edit_file_path = getView(R.id.edit_file_path); |
|
|
|
final EditText edit_live_url = (EditText) findViewById(R.id.edit_live_url); |
|
|
|
edit_live_url = getView(R.id.edit_live_url); |
|
|
|
edit_file_path.setText(FILE_PATH); |
|
|
|
edit_file_path.setText(FILE_PATH); |
|
|
|
edit_live_url.setText(LIVE_URL); |
|
|
|
edit_live_url.setText(LIVE_URL); |
|
|
|
|
|
|
|
|
|
|
|
Button btn_push_stream = (Button)findViewById(R.id.btn_push_stream); |
|
|
|
initViewsWithClick(R.id.btn_push_stream); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
btn_push_stream.setOnClickListener(new View.OnClickListener() { |
|
|
|
private void startPushStreaming() { |
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(View v) { |
|
|
|
|
|
|
|
//TODO 视频文件格式为flv
|
|
|
|
//TODO 视频文件格式为flv
|
|
|
|
final String filePath = edit_file_path.getText().toString(); |
|
|
|
final String filePath = edit_file_path.getText().toString(); |
|
|
|
final String liveUrl = edit_live_url.getText().toString(); |
|
|
|
final String liveUrl = edit_live_url.getText().toString(); |
|
|
@ -62,11 +66,20 @@ public class PushActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
}).start(); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
Toast.makeText(PushActivity.this, "文件不存在", Toast.LENGTH_SHORT).show(); |
|
|
|
showToast(getString(R.string.file_not_found)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
void onViewClick(View view) { |
|
|
|
|
|
|
|
if (view.getId() == R.id.btn_push_stream) { |
|
|
|
|
|
|
|
startPushStreaming(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
void onSelectedFile(String filePath) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|