SmartPublisherJni.java
7.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*
* SmartPublisherJni.java
* SmartPublisherJni
*
* Github: https://github.com/daniulive/SmarterStreaming
*
* Created by DaniuLive on 2015/09/20.
* Copyright © 2014~2016 DaniuLive. All rights reserved.
*/
package com.daniulive.smartpublisher;
import com.eventhandle.SmartEventCallback;
import java.nio.ByteBuffer;
public class SmartPublisherJni {
static class WATERMARK {
public static final int WATERMARK_FONTSIZE_MEDIUM = 0;
public static final int WATERMARK_FONTSIZE_SMALL = 1;
public static final int WATERMARK_FONTSIZE_BIG = 2;
public static final int WATERMARK_POSITION_TOPLEFT = 0;
public static final int WATERMARK_POSITION_TOPRIGHT = 1;
public static final int WATERMARK_POSITION_BOTTOMLEFT = 2;
public static final int WATERMARK_POSITION_BOTTOMRIGHT = 3;
}
/**
* Initialized publisher.
*
* @param ctx: get by this.getApplicationContext()
*
* @param audio_opt: if with 0: it does not publish audio; if with 1, it publish audio; if with 2, it publish external encoded audio, only support aac.
*
* @param video_opt: if with 0: it does not publish video; if with 1, it publish video; if with 2, it publish external encoded video, only support h264, data:0000000167....
*
* @param width: capture width; height: capture height.
*
* <pre>This function must be called firstly.</pre>
*
* @return {0} if successful
*/
public native int SmartPublisherInit(Object ctx, int audio_opt, int video_opt, int width, int height);
/**
* Set callback event
*
* @param callback function
*
* @return {0} if successful
*/
public native int SetSmartPublisherEventCallback(SmartEventCallback callback);
/**
* Set Video HW Encoder, if support HW encoder, it will return 0
*
* @param kbps: the kbps of different resolution(25 fps).
*
* @return {0} if successful
*/
public native int SetSmartPublisherVideoHWEncoder(int kbps);
/**
* Set Font water-mark
*
* @param fontSize: it should be "MEDIUM", "SMALL", "BIG"
*
* @param waterPostion: it should be "TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT".
*
* @param xPading, yPading: the distance of the original picture.
*
* <pre> The interface is only used for setting font water-mark when publishing stream. </pre>
*
* @return {0} if successful
*/
public native int SmartPublisherSetFontWatermark(String waterText, int isAppendTime, int fontSize, int waterPostion, int xPading, int yPading);
/**
* Set picture water-mark
*
* @param picPath: the picture working path, e.g: /sdcard/logo.png
*
* @param waterPostion: it should be "TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT".
*
* @param picWidth, picHeight: picture width & height
*
* @param xPading, yPading: the distance of the original picture.
*
* <pre> The interface is only used for setting picture(logo) water-mark when publishing stream, with "*.png" format </pre>
*
* @return {0} if successful
*/
public native int SmartPublisherSetPictureWatermark(String picPath, int waterPostion, int picWidth, int picHeight, int xPading, int yPading);
/**
* Set mute or not during publish stream
*
* @param isMute: if with 1:mute, if with 0: does not mute
*
* @return {0} if successful
*/
public native int SmartPublisherSetMute(int isMute);
/**
* Set if recorder the stream to local file.
*
* @param isRecorder: (0: do not recorder; 1: recorder)
*
* <pre> NOTE: If set isRecorder with 1: Please make sure before call SmartPublisherStartPublish(), set a valid path via SmartPublisherCreateFileDirectory(). </pre>
*
* @return {0} if successful
*/
public native int SmartPublisherSetRecorder(int isRecorder);
/**
* Create file directory
*
* @param path, E.g: /sdcard/daniulive/rec
*
* <pre> The interface is only used for recording the stream data to local side. </pre>
*
* @return {0} if successful
*/
public native int SmartPublisherCreateFileDirectory(String path);
/**
* Set recorder directory.
*
* @param path: the directory of recorder file.
*
* <pre> NOTE: make sure the path should be existed, or else the setting failed. </pre>
*
* @return {0} if successful
*/
public native int SmartPublisherSetRecorderDirectory(String path);
/**
* Set the size of every recorded file.
*
* @param size: (MB), (5M~500M), if not in this range, set default size with 200MB.
*
* @return {0} if successful
*/
public native int SmartPublisherSetRecorderFileMaxSize(int size);
/**
* Set rtmp PublishingType
*
* @param type: 0:live, 1:record. please refer to rtmp specification Page 46
*
* @return {0} if successful
*/
public native int SetRtmpPublishingType(int type);
/**
* Set publish stream url.
*
* if not set url or url is empty, it will not publish stream
*
* @param url: publish url.
*
* @return {0} if successful
*/
public native int SmartPublisherSetURL(String url);
/**
* Start publish stream
*
* @return {0} if successful
*/
public native int SmartPublisherStart();
/**
* Set live video data(no encoded data).
*
* @param cameraType: CAMERA_FACING_BACK with 0, CAMERA_FACING_FRONT with 1
*
* @param curOrg: LANDSCAPE with 0, PORTRAIT 1
*
* @return {0} if successful
*/
public native int SmartPublisherOnCaptureVideoData(byte[] data, int len, int cameraType, int curOrg);
/**
* Set live video data(no encoded data).
*
* @param data: I420 data
*
* @param len: I420 data length
*
* @param yStride: y stride
*
* @param uStride: u stride
*
* @param vStride: v stride
*
* @return {0} if successful
*/
public native int SmartPublisherOnCaptureVideoI420Data(byte[] data, int len, int yStride, int uStride, int vStride);
/**
* Set live video data(no encoded data).
*
* @param data: RGBA data
*
* @param rowStride: stride information
*
* @param width: width
*
* @param height: height
*
* @return {0} if successful
*/
public native int SmartPublisherOnCaptureVideoRGBAData(ByteBuffer data, int rowStride, int width, int height);
/**
* Set encoded video data.
*
* @param buffer: encoded video data
*
* @param len: data length
*
* @param isKeyFrame: if with key frame, please set 1, otherwise, set 0.
*
* @param timeStamp: video timestamp
*
* @return {0} if successful
*/
public native int SmartPublisherOnReceivingVideoEncodedData(byte[] buffer, int len, int isKeyFrame, long timeStamp);
/**
* set audio specific configure.
*
* @param buffer: audio specific settings.
*
* For example:
*
* sample rate with 44100, channel: 2, profile: LC
*
* audioConfig set as below:
*
* byte[] audioConfig = new byte[2];
* audioConfig[0] = 0x12;
* audioConfig[1] = 0x10;
*
* @param len: buffer length
*
* @return {0} if successful
*/
public native int SmartPublisherSetAudioSpecificConfig(byte[] buffer, int len);
/**
* Set encoded audio data.
*
* @param data: encoded audio data
*
* @param len: data length
*
* @param isKeyFrame: 1
*
* @param timeStamp: audio timestamp
*
* @return {0} if successful
*/
public native int SmartPublisherOnReceivingAACData(byte[] buffer, int len, int isKeyFrame, long timeStamp);
/**
* Stop publish stream
*
* @return {0} if successful
*/
public native int SmartPublisherStop();
}