Hello,
I am currently doing a simple service application that is making live broadcas of wowza apps, for me it is so clear that how to make streaming lively with wowza and i’ve reached that goal.
Currently, my expectations is to use also start recording in cases using url queries of wowza media engine, but somehow my implementations are always getting “401 unauthorized”. Trying to making it via browser always works with correct credentials, but Postman or java always get response as 401.
http://username:password@ipadress:8086/livestreamrecord/index.html
Above url, is easliy reachable from Chrome, but when i try to use Postman, i can’t get any result. I don’t know how i can start and stop recording by usage of below queries if i can’t manage to reach wowza media engine :
http://username:password@ipadress:8086/livestreamrecord?app=yanda&streamname=hayra&action=startRecording&outputFile=yanda_12347.mp4
http://username:password@ipadress:8086/livestreamrecord?app=yanda&streamname=hayra&action=stopRecording&outputFile=yanda_12347.mp4
I am using retrofit2 on my android application and here is the code that i am using it :
//WowzaIntefaceUtils
public class WowzaInterfaceUtils {
public static final String BASE_URL = "http://username:password@ipadress:8086/";
public static WowzaInterfaceController getWowzaInterfaceController(){
return WowzaInterfaceClient.getClient(BASE_URL).create(WowzaInterfaceController.class);
}
}
//WowzaInterfaceClient
*/
public class WowzaInterfaceClient {private static Retrofit retrofit = null;
public static Retrofit getClient(String baseUrl) {
if (retrofit==null) {
OkHttpClient.Builder client = new OkHttpClient.Builder();
client.followRedirects(false);
OkHttpClient httpClient = client.build();
retrofit = new Retrofit.Builder()
.baseUrl(baseUrl)
.client(httpClient)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
}
//WowzaInterfaceController
@GET("/livestreamrecord")
@Streaming
Call<ResponseBody> livestreamrecord(@Query("app") String app, @Query("streamname") String streamName,
@Query("action") String action, @Query("outputFile") String outputFile);
//On Retrofit call
public void startCameraRecording(String app, String streamName,String outputFile){
wowzaInterfaceController = WowzaInterfaceUtils.getWowzaInterfaceController();
Log.i("YTA_CameraRecording","Camera recording will be started");
wowzaInterfaceController.livestreamrecord(app,streamName,"startRecording",outputFile).enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
Log.i("YTA_CameraRecording", "Start camera responded : " + response.code());
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Log.e("YTA_CameraRecording", "Start camera failed");
}
});
}