Skip to content

Commit

Permalink
Merge pull request #3 from jpxiong/master
Browse files Browse the repository at this point in the history
release v1.0.2
  • Loading branch information
why404 committed Jun 29, 2015
2 parents 1496803 + 4b2f0e6 commit f6c28ff
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 24 deletions.
2 changes: 1 addition & 1 deletion PLDroidCameraStreamingDemo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile files('libs/pldroid-camera-streaming-1.0.1.jar')
compile files('libs/pldroid-camera-streaming-1.0.2.jar')
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import com.pili.pldroid.streaming.StreamingProfile.Stream;
import com.pili.pldroid.streaming.widget.AspectFrameLayout;

import org.json.JSONException;
import org.json.JSONObject;

/**
* Created by jerikc on 15/6/16.
*/
Expand All @@ -45,7 +48,12 @@ public void handleMessage(Message msg) {
mShutterButtonPressed = !mShutterButtonPressed;
mShutterButton.setPressed(mShutterButtonPressed);
if (mShutterButtonPressed) {
mCameraStreamingManager.startStreaming();
boolean res = mCameraStreamingManager.startStreaming();
Log.i(TAG, "res:" + res);
if (!res) {
mShutterButtonPressed = !mShutterButtonPressed;
mShutterButton.setPressed(mShutterButtonPressed);
}
} else {
mCameraStreamingManager.stopStreaming();
}
Expand Down Expand Up @@ -73,17 +81,53 @@ protected void onCreate(Bundle savedInstanceState) {

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
//
// get the followings from server
String publishHost = "publish host from server"; // such as "f9zdwh.pub.z1.pili.qiniup.com"
String streamId = "stream id from server"; // such as "z1.live.558cf018e3ba570400000010"
String publishKey = "publish key from server"; // such as "c4da83f14319d349"
String publishSecurity = "publish security from server"; // such as "dynamic" or "static", "dynamic" is recommended

Stream stream = new Stream(publishHost, streamId, publishKey, publishSecurity);

// Get publish host from your server
String publishHost = "publish host from server"; // such as "f9zdwh.pub.z1.pili.qiniup.com"
/*
* You should get the streamJson from your server, maybe like this:
*
* Step 1: Get streamJsonStrFromServer from server
* URL url = new URL(yourURL);
* URLConnection conn = url.openConnection();
*
* HttpURLConnection httpConn = (HttpURLConnection) conn;
* httpConn.setAllowUserInteraction(false);
* httpConn.setInstanceFollowRedirects(true);
* httpConn.setRequestMethod("GET");
* httpConn.connect();
*
* InputStream is = httpConn.getInputStream();
* streamJsonStrFromServer = convertInputStreamToString(is);
*
* Step 2: Instantiate streamJson object
* JSONObject streamJson = new JSONObject(streamJsonStrFromServer);
*
*
* Then you can use streamJson to instantiate stream object
* Stream stream = new Stream(streamJson);
*
* */
String streamJsonStrFromServer = "{"
+ "\"id\" :\"z1.live.55910c19fb16df0cbf00af8e\", "
+ "\"hub\" :\"live\", "
+ "\"title\" :\"55910c19fb16df0cbf00af8e\", "
+ "\"publishKey\" :\"b06c7427b454762c\", "
+ "\"publishSecurity\":\"dynamic\", "
+ "..."
+ "}";

JSONObject streamJson = null;
try {
streamJson = new JSONObject(streamJsonStrFromServer);
} catch (JSONException e) {
e.printStackTrace();
}

Stream stream = new Stream(streamJson);
StreamingProfile profile = new StreamingProfile();
profile.setQuality(StreamingProfile.QUALITY_LOW1)
.setStream(stream);
.setStreamAndPublishhost(stream, publishHost);

CameraStreamingSetting setting = new CameraStreamingSetting();
setting.setCameraId(Camera.CameraInfo.CAMERA_FACING_BACK)
Expand Down Expand Up @@ -156,6 +200,8 @@ public void onStateChanged(final int state) {
break;
case STATE.READY:
mStatusMsgContent = getString(R.string.string_state_ready);
// start streaming when READY
onShutterButtonClick();
break;
case STATE.CONNECTING:
mStatusMsgContent = getString(R.string.string_state_connecting);
Expand Down
80 changes: 67 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,69 @@ GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.cameraPreview_su

3) 实例化并初始化 `StreamingProfile``Stream``CameraStreamingSetting`

配置 `Stream` 各项参数,SDK 会通过 `Stream` 对象生成必要的推流信息。
`streamJsonStrFromServer` 是由服务端返回的一段 JSON String,该 JSON String 描述了 `Stream` 的结构。通常,您可以使用 Pili 服务端 SDK `getStream(streamId)` 方法来获取一个 `Stream` 对象,在服务端并将该对象以 JSON String 格式输出,该输出即是 `streamJsonStrFromServer` 变量的内容。例如,一段 JSON 格式的 `Stream` 内容如下:

>注意以下配置为 `Stream` 对象构造所必需,若参数非法,将会得到 `java.lang.IllegalArgumentException`
```JAVA
// get the followings from server
String publishHost = "publish host from server"; // such as "f9zdwh.pub.z1.pili.qiniup.com"
String streamId = "stream id from server"; // such as "z1.live.558cf018e3ba570400000010"
String publishKey = "publish key from server"; // such as "c4da83f14319d349"
String publishSecurity = "publish security from server"; // such as "dynamic" or "static", "dynamic" is recommended
```
{
"id": "xxx",
"hub": "live",
"title": "xxx",
"publishKey": "xxx",
"publishSecurity": "xxx",
// ...
}
```
然后根据 `streamJsonStrFromServer` 构造 `JSONObject` 类型的对象 `streamJson`

```JAVA
Stream stream = new Stream(publishHost, streamId, publishKey, publishSecurity);
// Get publish host from your server
String publishHost = "publish host from server"; // such as "f9zdwh.pub.z1.pili.qiniup.com"
/*
*
* You should get the streamJson from your server, maybe like this:
*
* Step 1: Get streamJsonStrFromServer from server
* URL url = new URL(yourURL);
* URLConnection conn = url.openConnection();
*
* HttpURLConnection httpConn = (HttpURLConnection) conn;
* httpConn.setAllowUserInteraction(false);
* httpConn.setInstanceFollowRedirects(true);
* httpConn.setRequestMethod("GET");
* httpConn.connect();
*
* InputStream is = httpConn.getInputStream();
* streamJsonStrFromServer = convertInputStreamToString(is);
*
* Step 2: Instantiate streamJson object
* JSONObject streamJson = new JSONObject(streamJsonStrFromServer);
*
*
* Then you can use streamJson to instantiate stream object
* Stream stream = new Stream(streamJson);
*
* */
String streamJsonStrFromServer = "{"
+ "\"id\" :\"z1.live.55910c19fb16df0cbf00af8e\", "
+ "\"hub\" :\"live\", "
+ "\"title\" :\"55910c19fb16df0cbf00af8e\", "
+ "\"publishKey\" :\"b06c7427b454762c\", "
+ "\"publishSecurity\":\"dynamic\", "
+ "..."
+ "}";

JSONObject streamJson = null;
try {
streamJson = new JSONObject(streamJsonStrFromServer);
} catch (JSONException e) {
e.printStackTrace();
}

Stream stream = new Stream(streamJson);

StreamingProfile profile = new StreamingProfile();
profile.setQuality(StreamingProfile.QUALITY_MEDIUM1)
.setStream(stream);
.setStreamAndPublishhost(stream, publishHost);

CameraStreamingSetting setting = new CameraStreamingSetting();
setting.setCameraId(Camera.CameraInfo.CAMERA_FACING_BACK)
Expand Down Expand Up @@ -136,6 +181,7 @@ mCameraStreamingManager.setStreamingStateListener(this);
5) 开始推流
```JAVA
// should be invoked after getting STATE.READY message
mCameraStreamingManager.startStreaming();
```

Expand Down Expand Up @@ -173,10 +219,17 @@ protected void onDestroy() {
- FFMPEG

### 版本历史
* 1.0.2 ([Release Notes][6])
- 发布 pldroid-camera-streaming-1.0.2.jar
- 修复无 `StreamingStateListener` 情况下的 Crash 问题
- 修复正常启动后无 READY 消息返回问题
- 更新 `Stream` 定义,并与服务端保持一致
- 增加相机正常启动后即开始推流功能

* 1.0.1 ([Release Notes][5])
- 发布 pldroid-camera-streaming-1.0.1.jar
- 更新 Stream 类结构
- 更新 Stream 的构造方式
- 更新 `Stream` 类结构
- 更新 `Stream` 的构造方式

* 1.0.0 ([Release Notes][4])
- 发布 PLDroidCameraStreaming v1.0.0
Expand All @@ -187,3 +240,4 @@ protected void onDestroy() {
[3]: /PLDroidCameraStreamingDemo/app/src/main/java/com/pili/pldroid/streaming/camera/demo/CameraStreamingActivity.java
[4]: /ReleaseNotes/release-notes-1.0.0.md
[5]: /ReleaseNotes/release-notes-1.0.1.md
[6]: /ReleaseNotes/release-notes-1.0.2.md
16 changes: 16 additions & 0 deletions ReleaseNotes/release-notes-1.0.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# PLDroidCameraStreaming Release Notes for 1.0.2

## 简介
PLDroidCameraStreaming 是为 Android 开发者提供的 RTMP 直播推流 SDK

## 记录

### 推流 SDK
* 发布 pldroid-camera-streaming-1.0.2.jar
* 修复无 `StreamingStateListener` 情况下的 Crash 问题
* 修复正常启动后无 READY 消息返回问题
* 更新 `Stream` 定义,并与服务端保持一致


### Demo
* 增加相机启动后即开始推流功能
Binary file added releases/pldroid-camera-streaming-1.0.2.jar
Binary file not shown.

0 comments on commit f6c28ff

Please sign in to comment.