Search in sources :

Example 1 with AudioStat

use of com.aliyun.oss.model.LiveChannelStat.AudioStat in project aliyun-oss-java-sdk by aliyun.

the class ResponseParsers method parseGetLiveChannelStat.

/**
 * Unmarshall get live channel stat response body to corresponding result.
 */
public static LiveChannelStat parseGetLiveChannelStat(InputStream responseBody) throws ResponseParseException {
    try {
        Element root = getXmlRootElement(responseBody);
        LiveChannelStat result = new LiveChannelStat();
        result.setPushflowStatus(PushflowStatus.parse(root.getChildText("Status")));
        if (root.getChild("ConnectedTime") != null) {
            result.setConnectedDate(DateUtil.parseIso8601Date(root.getChildText("ConnectedTime")));
        }
        if (root.getChild("RemoteAddr") != null) {
            result.setRemoteAddress(root.getChildText("RemoteAddr"));
        }
        Element videoElem = root.getChild("Video");
        if (videoElem != null) {
            VideoStat videoStat = new VideoStat();
            videoStat.setWidth(Integer.parseInt(videoElem.getChildText("Width")));
            videoStat.setHeight(Integer.parseInt(videoElem.getChildText("Height")));
            videoStat.setFrameRate(Integer.parseInt(videoElem.getChildText("FrameRate")));
            videoStat.setBandWidth(Integer.parseInt(videoElem.getChildText("Bandwidth")));
            videoStat.setCodec(videoElem.getChildText("Codec"));
            result.setVideoStat(videoStat);
        }
        Element audioElem = root.getChild("Audio");
        if (audioElem != null) {
            AudioStat audioStat = new AudioStat();
            audioStat.setBandWidth(Integer.parseInt(audioElem.getChildText("Bandwidth")));
            audioStat.setSampleRate(Integer.parseInt(audioElem.getChildText("SampleRate")));
            audioStat.setCodec(audioElem.getChildText("Codec"));
            result.setAudioStat(audioStat);
        }
        return result;
    } catch (JDOMParseException e) {
        throw new ResponseParseException(e.getPartialDocument() + ": " + e.getMessage(), e);
    } catch (Exception e) {
        throw new ResponseParseException(e.getMessage(), e);
    }
}
Also used : JDOMParseException(org.jdom.input.JDOMParseException) AudioStat(com.aliyun.oss.model.LiveChannelStat.AudioStat) Element(org.jdom.Element) ResponseParseException(com.aliyun.oss.common.parser.ResponseParseException) VideoStat(com.aliyun.oss.model.LiveChannelStat.VideoStat) LiveChannelStat(com.aliyun.oss.model.LiveChannelStat) ParseException(java.text.ParseException) JDOMParseException(org.jdom.input.JDOMParseException) ResponseParseException(com.aliyun.oss.common.parser.ResponseParseException)

Aggregations

ResponseParseException (com.aliyun.oss.common.parser.ResponseParseException)1 LiveChannelStat (com.aliyun.oss.model.LiveChannelStat)1 AudioStat (com.aliyun.oss.model.LiveChannelStat.AudioStat)1 VideoStat (com.aliyun.oss.model.LiveChannelStat.VideoStat)1 ParseException (java.text.ParseException)1 Element (org.jdom.Element)1 JDOMParseException (org.jdom.input.JDOMParseException)1