LiveQing streaming media server software provides one-stop transcoding, on-demand, live, and time-shift playback services, greatly simplifying development and integration.

Among them, the vod function mainly includes: upload, transcoding, distribution. Live broadcast functions mainly include: live broadcast and video recording. Live broadcast supports RTMP input and RTMP/HLS/HTTP-FLV distribution output. Videos can be saved for a customized duration, retrieved and downloaded. Provides rich secondary development interface, jSON-based packaging and HTTP call. Provides security guarantees such as broadcast and push stream authentication. Provides user and permission management configurations.

1. Interface list

demo.liveqing.com:10080/apidoc/

Second, integrated secondary development

In secondary development, you can invoke the streaming media login interface from the back-end login interface of your own service system to obtain the required SID or token

1. Closed Intranet use

In service use, if LiveQing is used only to provide video distribution capability and does not expose interface port 10080(the default port), you can directly disable interface authentication. The default user name and password for logging in to http://localhost:10080 are admin and admin. On the basic configuration page, switch interface Authentication.

2. Service system interconnection (two methods)

2.1 the cookie way

Note: HttpOnly = true Client apis (such as JavaScript) cannot access HTTP-only cookies. This restriction eliminates the threat of cookie theft through cross-site scripting (XSS).

  1. Connect to back-end business code, such as Java/PHP/Node.js
  2. If the LiveQing login interface is successfully invoked, sid will be written to the cookie requesting Headers
  3. Retrieve sid from cookie
  4. The SID is passed in request header cookies when other interfaces are called
  5. Content-Type:application/x-www-form-urlencoded
  6. Interface request path example: http://localhost:10080/login

Code example: Java

2.1.1 obtain sid

import java.io.DataOutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; public class GetLoginSid { public static void main(String[] args) throws Exception { URL url = new URL("http://cloud.liveqing.com:10080/login"); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); // Initiate a POST request and pass the username and password parameters (md5 encryption required). conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); DataOutputStream out = new DataOutputStream(conn.getOutputStream()); String content = "username=admin&password=21232f297a57a5a743894a0e4a801fc3"; out.writeBytes(content); out.flush(); out.close(); Map<String, List<String>> headerFields = conn.getHeaderFields(); Set<String> headerFieldsSet = headerFields.keySet(); Iterator<String> hearerFieldsIter = headerFieldsSet.iterator(); while (hearerFieldsIter.hasNext()) { String headerFieldKey = hearerFieldsIter.next(); if ("Set-Cookie".equalsIgnoreCase(headerFieldKey)) { List<String> headerFieldValue = headerFields.get(headerFieldKey); for (String headerValue : headerFieldValue) { String[] fields = headerValue.split("; \\s*"); for (int j = 0; j < fields.length; j++) { if (fields[j].indexOf('=') > 0) { String[] f = fields[j].split("="); if ("Expires".equalsIgnoreCase(f[0])) { System.out.println("Expires:" + f[1]); } else if ("Max-Age".equalsIgnoreCase(f[0])) { System.out.println("Max-Age:" + f[1]); }else if ("sid".equalSignoRecase (f[0])) {// Get sid system.out.println ("sid:" + f[1]); } } } } } } } }Copy the code

Run the following

2.1.2 Invoking Other Interfaces with SID

import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class RequestOtherAPI { public static void main(String[] args) throws Exception { URL url = new URL("http://demo.liveqing.com:10080/live/list"); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); / / step here passed on the sid conn. SetRequestProperty (" Cookie ", "sid = s % 3 ano - TEuVtm. WnWoXuDY % 2 fldjuec64i6txjd0fq1eqbyed4ng1uwnb2i;" ); DataOutputStream out = new DataOutputStream(conn.getOutputStream()); String content = "start=0&limit=10"; out.writeBytes(content); out.flush(); out.close(); conn.connect(); StringBuffer sbf = new StringBuffer(); InputStream is = conn.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); String strRead = null; while ((strRead = reader.readLine()) ! = null) { sbf.append(strRead); sbf.append("\r\n"); } reader.close(); System.out.println(sbf.toString()); }}Copy the code

2.2 token way

  1. Call the login interface to get token, call transfer onlytoken = true, such as: demo.liveqing.com: 10080 / login? Usern…
  2. Content-Type:application/x-www-form-urlencoded
  3. Other interface calls pass additional token input arguments

Code example: Java

2.2.1 access token

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class GetLoginToken {

public static void main(String[] args) throws Exception {
        URL url = new URL("http://localhost:10080/login");
        HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setRequestMethod("POST");     
        conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
        DataOutputStream out = new DataOutputStream(conn.getOutputStream()); 
            String content = "username=admin&password=21232f297a57a5a743894a0e4a801fc3";
            out.writeBytes(content);
            out.flush(); 
            out.close();
            conn.connect();
            StringBuffer sbf = new StringBuffer();
            InputStream is = conn.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            String strRead = null;
            while ((strRead = reader.readLine()) != null) {
                sbf.append(strRead);
                sbf.append("\r\n");
            }
            reader.close();
            System.out.println(sbf.toString());
    }
  }
Copy the code

Run the following

2.2.2 Invoking Other Interfaces with a Token

When other interfaces call, the token input parameter is appended

import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class RequestOtherAPIByToken { public static void main(String[] args) throws Exception { URL url = new URL("http://localhost:10080/live/list"); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); DataOutputStream out = new DataOutputStream(conn.getOutputStream()); String content = "start=0&limit=10&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1Mzc3NzExNTAsInB3IjoiMjEyMzJmMjk3YTU3YTVhNzQzODk 0YTBlNGE4MDFmYzMiLCJ0bSI6MTUzNzY4NDc1MCwidW4iOiJhZG1pbiJ9.b1U-R-_HVKV9reWRD50327B1ztUqs3gowUGi_lDzlmU"; out.writeBytes(content); out.flush(); out.close(); conn.connect(); StringBuffer sbf = new StringBuffer(); InputStream is = conn.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); String strRead = null; while ((strRead = reader.readLine()) ! = null) { sbf.append(strRead); sbf.append("\r\n"); } reader.close(); System.out.println(sbf.toString()); }}Copy the code

Run the following