ex
Fork of mbed-os-example-mbed5-blinky by
dcs-sdk-java-master/app/src/main/java/com/baidu/duer/dcs/devicemodule/audioplayer/message/PlayPayload.java@45:2aa9f933c8d2, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:34:48 2017 +0800
- Revision:
- 45:2aa9f933c8d2
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 45:2aa9f933c8d2 | 1 | /* |
| TMBOY | 45:2aa9f933c8d2 | 2 | * Copyright (c) 2017 Baidu, Inc. All Rights Reserved. |
| TMBOY | 45:2aa9f933c8d2 | 3 | * |
| TMBOY | 45:2aa9f933c8d2 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| TMBOY | 45:2aa9f933c8d2 | 5 | * you may not use this file except in compliance with the License. |
| TMBOY | 45:2aa9f933c8d2 | 6 | * You may obtain a copy of the License at |
| TMBOY | 45:2aa9f933c8d2 | 7 | * |
| TMBOY | 45:2aa9f933c8d2 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| TMBOY | 45:2aa9f933c8d2 | 9 | * |
| TMBOY | 45:2aa9f933c8d2 | 10 | * Unless required by applicable law or agreed to in writing, software |
| TMBOY | 45:2aa9f933c8d2 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| TMBOY | 45:2aa9f933c8d2 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| TMBOY | 45:2aa9f933c8d2 | 13 | * See the License for the specific language governing permissions and |
| TMBOY | 45:2aa9f933c8d2 | 14 | * limitations under the License. |
| TMBOY | 45:2aa9f933c8d2 | 15 | */ |
| TMBOY | 45:2aa9f933c8d2 | 16 | package com.baidu.duer.dcs.devicemodule.audioplayer.message; |
| TMBOY | 45:2aa9f933c8d2 | 17 | |
| TMBOY | 45:2aa9f933c8d2 | 18 | import com.baidu.duer.dcs.framework.message.Payload; |
| TMBOY | 45:2aa9f933c8d2 | 19 | |
| TMBOY | 45:2aa9f933c8d2 | 20 | import org.codehaus.jackson.annotate.JsonIgnore; |
| TMBOY | 45:2aa9f933c8d2 | 21 | |
| TMBOY | 45:2aa9f933c8d2 | 22 | import java.io.InputStream; |
| TMBOY | 45:2aa9f933c8d2 | 23 | import java.io.Serializable; |
| TMBOY | 45:2aa9f933c8d2 | 24 | |
| TMBOY | 45:2aa9f933c8d2 | 25 | /** |
| TMBOY | 45:2aa9f933c8d2 | 26 | * Audio Player模块Play指令对应的payload结构 |
| TMBOY | 45:2aa9f933c8d2 | 27 | * <p> |
| TMBOY | 45:2aa9f933c8d2 | 28 | * Created by guxiuzhong@baidu.com on 2017/5/31. |
| TMBOY | 45:2aa9f933c8d2 | 29 | */ |
| TMBOY | 45:2aa9f933c8d2 | 30 | public class PlayPayload extends Payload { |
| TMBOY | 45:2aa9f933c8d2 | 31 | public PlayBehavior playBehavior; |
| TMBOY | 45:2aa9f933c8d2 | 32 | public AudioItem audioItem; |
| TMBOY | 45:2aa9f933c8d2 | 33 | |
| TMBOY | 45:2aa9f933c8d2 | 34 | public enum PlayBehavior { |
| TMBOY | 45:2aa9f933c8d2 | 35 | REPLACE_ALL, |
| TMBOY | 45:2aa9f933c8d2 | 36 | ENQUEUE, |
| TMBOY | 45:2aa9f933c8d2 | 37 | REPLACE_ENQUEUED |
| TMBOY | 45:2aa9f933c8d2 | 38 | } |
| TMBOY | 45:2aa9f933c8d2 | 39 | |
| TMBOY | 45:2aa9f933c8d2 | 40 | public static class AudioItem implements Serializable { |
| TMBOY | 45:2aa9f933c8d2 | 41 | public String audioItemId; |
| TMBOY | 45:2aa9f933c8d2 | 42 | public Stream stream; |
| TMBOY | 45:2aa9f933c8d2 | 43 | } |
| TMBOY | 45:2aa9f933c8d2 | 44 | |
| TMBOY | 45:2aa9f933c8d2 | 45 | public static class Stream implements Serializable { |
| TMBOY | 45:2aa9f933c8d2 | 46 | public String url; |
| TMBOY | 45:2aa9f933c8d2 | 47 | public String token; |
| TMBOY | 45:2aa9f933c8d2 | 48 | public String expiryTime; |
| TMBOY | 45:2aa9f933c8d2 | 49 | public long offsetInMilliseconds; |
| TMBOY | 45:2aa9f933c8d2 | 50 | public String expectedPreviousToken; |
| TMBOY | 45:2aa9f933c8d2 | 51 | public String streamFormat; |
| TMBOY | 45:2aa9f933c8d2 | 52 | public boolean urlIsAContentId; |
| TMBOY | 45:2aa9f933c8d2 | 53 | public ProgressReport progressReport; |
| TMBOY | 45:2aa9f933c8d2 | 54 | @JsonIgnore |
| TMBOY | 45:2aa9f933c8d2 | 55 | public InputStream attachedContent; |
| TMBOY | 45:2aa9f933c8d2 | 56 | |
| TMBOY | 45:2aa9f933c8d2 | 57 | public boolean getProgressReportRequired() { |
| TMBOY | 45:2aa9f933c8d2 | 58 | return progressReport != null && progressReport.isRequired(); |
| TMBOY | 45:2aa9f933c8d2 | 59 | } |
| TMBOY | 45:2aa9f933c8d2 | 60 | |
| TMBOY | 45:2aa9f933c8d2 | 61 | public void setUrl(String url) { |
| TMBOY | 45:2aa9f933c8d2 | 62 | urlIsAContentId = url.startsWith("cid"); |
| TMBOY | 45:2aa9f933c8d2 | 63 | if (urlIsAContentId) { |
| TMBOY | 45:2aa9f933c8d2 | 64 | this.url = url.substring(4); |
| TMBOY | 45:2aa9f933c8d2 | 65 | } else { |
| TMBOY | 45:2aa9f933c8d2 | 66 | this.url = url; |
| TMBOY | 45:2aa9f933c8d2 | 67 | } |
| TMBOY | 45:2aa9f933c8d2 | 68 | } |
| TMBOY | 45:2aa9f933c8d2 | 69 | |
| TMBOY | 45:2aa9f933c8d2 | 70 | public boolean requiresAttachedContent() { |
| TMBOY | 45:2aa9f933c8d2 | 71 | return urlIsAContentId && !hasAttachedContent(); |
| TMBOY | 45:2aa9f933c8d2 | 72 | } |
| TMBOY | 45:2aa9f933c8d2 | 73 | |
| TMBOY | 45:2aa9f933c8d2 | 74 | public boolean hasAttachedContent() { |
| TMBOY | 45:2aa9f933c8d2 | 75 | return attachedContent != null; |
| TMBOY | 45:2aa9f933c8d2 | 76 | } |
| TMBOY | 45:2aa9f933c8d2 | 77 | |
| TMBOY | 45:2aa9f933c8d2 | 78 | @JsonIgnore |
| TMBOY | 45:2aa9f933c8d2 | 79 | public InputStream getAttachedContent() { |
| TMBOY | 45:2aa9f933c8d2 | 80 | return attachedContent; |
| TMBOY | 45:2aa9f933c8d2 | 81 | } |
| TMBOY | 45:2aa9f933c8d2 | 82 | } |
| TMBOY | 45:2aa9f933c8d2 | 83 | |
| TMBOY | 45:2aa9f933c8d2 | 84 | public static class ProgressReport implements Serializable { |
| TMBOY | 45:2aa9f933c8d2 | 85 | public long progressReportDelayInMilliseconds; |
| TMBOY | 45:2aa9f933c8d2 | 86 | public long progressReportIntervalInMilliseconds; |
| TMBOY | 45:2aa9f933c8d2 | 87 | |
| TMBOY | 45:2aa9f933c8d2 | 88 | public boolean isRequired() { |
| TMBOY | 45:2aa9f933c8d2 | 89 | return progressReportDelayInMilliseconds > 0 || progressReportIntervalInMilliseconds > 0; |
| TMBOY | 45:2aa9f933c8d2 | 90 | } |
| TMBOY | 45:2aa9f933c8d2 | 91 | } |
| TMBOY | 45:2aa9f933c8d2 | 92 | } |
