1 /**
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.telephony.imsmedia;
18 
19 import android.annotation.IntDef;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 
23 import androidx.annotation.NonNull;
24 import androidx.annotation.Nullable;
25 
26 import java.lang.annotation.Retention;
27 import java.lang.annotation.RetentionPolicy;
28 import java.util.Objects;
29 
30 /**
31  * The class represents RTP (Real Time Control) configuration for video stream.
32  *
33  * @hide
34  */
35 public final class VideoConfig extends RtpConfig {
36 
37     /** The mode that camera preview is displaying in the preview surface and the video frame does
38     * not go out to the network. It is set in the case of the Ring-Go, Ring-back and in the
39     * direction is RECEIVE_ONLY.
40     */
41     public static final int VIDEO_MODE_PREVIEW = 0;
42     /** The camera is in recording mode and camera frame is displaying in preview surface and
43     * frames are going out to the network in cases the MediaDirection is set as SEND_ONLY or
44     * SEND_RECEIVE.
45     */
46     public static final int VIDEO_MODE_RECORDING = 1;
47     /** An image is displayed in the preview surface and streaming to the network. The image is set
48     * by the VideoConfig.
49     */
50     public static final int VIDEO_MODE_PAUSE_IMAGE = 2;
51 
52     /** @hide */
53     @IntDef(
54         flag = true,
55         value = {
56             VIDEO_MODE_PREVIEW,
57             VIDEO_MODE_RECORDING,
58             VIDEO_MODE_PAUSE_IMAGE,
59     })
60     @Retention(RetentionPolicy.SOURCE)
61     public @interface VideoMode {}
62 
63     /** AVC video codec */
64     public static final int VIDEO_CODEC_AVC = 1 << 5;
65     /** HEVC video codec */
66     public static final int VIDEO_CODEC_HEVC = 1 << 6;
67 
68     /** @hide */
69     @IntDef(
70         flag = true,
71         value = {
72             VIDEO_CODEC_AVC,
73             VIDEO_CODEC_HEVC,
74     })
75     @Retention(RetentionPolicy.SOURCE)
76     public @interface CodecType {}
77 
78     /** Codec profile is not specified */
79     public static final int CODEC_PROFILE_NONE = 0;
80     /** AVC Codec Baseline profile */
81     public static final int AVC_PROFILE_BASELINE = 1;
82     /** AVC Codec Constrained Baseline profile */
83     public static final int AVC_PROFILE_CONSTRAINED_BASELINE = 0x00010000;
84     /** AVC Codec Constrained High profile */
85     public static final int AVC_PROFILE_CONSTRAINED_HIGH = 0x00080000;
86     /** AVC Codec High profile */
87     public static final int AVC_PROFILE_HIGH = 0x00000008;
88     /** AVC Codec Main profile */
89     public static final int AVC_PROFILE_MAIN = 0x00000002;
90     /** HEVC Codec Main profile */
91     public static final int HEVC_PROFILE_MAIN = 0x00000001;
92     /** HEVC Codec Main 10 profile */
93     public static final int HEVC_PROFILE_MAIN10 = 0x00000002;
94 
95     /** @hide */
96     @IntDef(
97         flag = true,
98         value = {
99             CODEC_PROFILE_NONE,
100             AVC_PROFILE_BASELINE,
101             AVC_PROFILE_CONSTRAINED_BASELINE,
102             AVC_PROFILE_CONSTRAINED_HIGH,
103             AVC_PROFILE_HIGH,
104             AVC_PROFILE_MAIN,
105             HEVC_PROFILE_MAIN,
106             HEVC_PROFILE_MAIN10,
107         })
108     @Retention(RetentionPolicy.SOURCE)
109     public @interface CodecProfile {}
110 
111     /** Video codec level is not specified */
112     public static final int CODEC_LEVEL_NONE = 0;
113     /** AVC Codec level 1 : 176x144, 64kbps, 15.0fps for QCIF */
114     public static final int AVC_LEVEL_1 = 1;
115     /** AVC Codec level 1b : 176x144, 128kbps, 15.0fps for QCIF */
116     public static final int AVC_LEVEL_1B = 0x00000002;
117     /** AVC Codec level 1.1 : 352x288, 192kbps, 10.0fps for QVGA, 7.5fps for CIF */
118     public static final int AVC_LEVEL_11 = 0x00000004;
119     /** AVC Codec level 1.2 : 352x288, 384kbps, 20.0fps for QVGA, 15.1fps for CIF */
120     public static final int AVC_LEVEL_12 = 0x00000008;
121     /** AVC Codec level 1.3 : 352x288, 768kbps, 39.6fps for QVGA, 30.0fps for CIF */
122     public static final int AVC_LEVEL_13 = 0x00000010;
123     /** AVC Codec level 2.0 : 352x288, 2Mbps */
124     public static final int AVC_LEVEL_2 = 0x00000020;
125     /** AVC Codec level 2.1 : 704x288, 352x576, 4Mbps */
126     public static final int AVC_LEVEL_21 = 0x00000040;
127     /** AVC Codec level 2.2 : 720x576, 4Mbps */
128     public static final int AVC_LEVEL_22 = 0x00000080;
129     /** AVC Codec level 3.0 : 720x576, 10Mbps */
130     public static final int AVC_LEVEL_3 = 0x00000100;
131     /** AVC Codec level 3.1 : 1280x720, 14Mbps */
132     public static final int AVC_LEVEL_31 = 0x00000200;
133     /** HEVC Codec high tier level 1 */
134     public static final int HEVC_HIGHTIER_LEVEL_1 = 0x00000002;
135     /** HEVC Codec high tier level 2 */
136     public static final int HEVC_HIGHTIER_LEVEL_2 = 0x00000008;
137     /** HEVC Codec high tier level 2.1 */
138     public static final int HEVC_HIGHTIER_LEVEL_21 = 0x00000020;
139     /** HEVC Codec high tier level 3 */
140     public static final int HEVC_HIGHTIER_LEVEL_3 = 0x00000080;
141     /** HEVC Codec high tier level 3.1 */
142     public static final int HEVC_HIGHTIER_LEVEL_31 = 0x00000200;
143     /** HEVC Codec high tier level 4 */
144     public static final int HEVC_HIGHTIER_LEVEL_4 = 0x00000800;
145     /** HEVC Codec high tier level 4.1 */
146     public static final int HEVC_HIGHTIER_LEVEL_41 = 0x00002000;
147     /** HEVC Codec main tier level 1 */
148     public static final int HEVC_MAINTIER_LEVEL_1 = 0x00000001;
149     /** HEVC Codec main tier level 2 */
150     public static final int HEVC_MAINTIER_LEVEL_2 = 0x00000004;
151     /** HEVC Codec main tier level 2.1 */
152     public static final int HEVC_MAINTIER_LEVEL_21 = 0x00000010;
153     /** HEVC Codec main tier level 3 */
154     public static final int HEVC_MAINTIER_LEVEL_3 = 0x00000040;
155     /** HEVC Codec main tier level 3.1 */
156     public static final int HEVC_MAINTIER_LEVEL_31 = 0x00000100;
157     /** HEVC Codec main tier level 4 */
158     public static final int HEVC_MAINTIER_LEVEL_4 = 0x00000400;
159     /** HEVC Codec main tier level 4.1 */
160     public static final int HEVC_MAINTIER_LEVEL_41 = 0x00001000;
161 
162     /** @hide */
163     @IntDef(
164         flag = true,
165         value = {
166             CODEC_LEVEL_NONE,
167             AVC_LEVEL_1,
168             AVC_LEVEL_1B,
169             AVC_LEVEL_11,
170             AVC_LEVEL_12,
171             AVC_LEVEL_13,
172             AVC_LEVEL_2,
173             AVC_LEVEL_21,
174             AVC_LEVEL_22,
175             AVC_LEVEL_3,
176             AVC_LEVEL_31,
177             HEVC_HIGHTIER_LEVEL_1,
178             HEVC_HIGHTIER_LEVEL_2,
179             HEVC_HIGHTIER_LEVEL_21,
180             HEVC_HIGHTIER_LEVEL_3,
181             HEVC_HIGHTIER_LEVEL_31,
182             HEVC_HIGHTIER_LEVEL_4,
183             HEVC_HIGHTIER_LEVEL_41,
184             HEVC_MAINTIER_LEVEL_1,
185             HEVC_MAINTIER_LEVEL_2,
186             HEVC_MAINTIER_LEVEL_21,
187             HEVC_MAINTIER_LEVEL_3,
188             HEVC_MAINTIER_LEVEL_31,
189             HEVC_MAINTIER_LEVEL_4,
190             HEVC_MAINTIER_LEVEL_41,
191         })
192     @Retention(RetentionPolicy.SOURCE)
193     public @interface CodecLevel {}
194 
195     /** Only single NAL unit packets MAY be used in this mode.
196      * STAPs, MTAPs, and FUs MUST NOT be used. Check RFC 6184 */
197     public static final int MODE_SINGLE_NAL_UNIT = 0;
198     /** Only single NAL unit packets, STAP-As, and FU-As MAY be used in this mode.
199      * STAP-Bs, MTAPs, and FU-Bs MUST NOT be used.  The transmission order of NAL units
200      * MUST comply with the NAL unit decoding order. Check RFC 6184*/
201     public static final int MODE_NON_INTERLEAVED = 1;
202     /** STAP-Bs, MTAPs, FU-As, and FU-Bs MAY be used.  STAP-As and single NAL unit packets
203      * MUST NOT be used.  The transmission order of packets and NAL units is constrained in
204      * certain rule, check RFC 6184. */
205     public static final int MODE_INTERLEAVED = 2;
206 
207     /** @hide */
208     @IntDef(
209         flag = true,
210         value = {
211             MODE_SINGLE_NAL_UNIT,
212             MODE_NON_INTERLEAVED,
213             MODE_INTERLEAVED,
214     })
215     @Retention(RetentionPolicy.SOURCE)
216     public @interface PacketizationMode {}
217 
218     public static final int RTP_FB_NONE = 0;
219     /**
220      * The Generic NACK(Negative Acknowledgement) message identified by RTCP packet type
221      * value PT=RTPFB and FMT=1. RFC 4585.
222      */
223     public static final int RTPFB_NACK = 1 << 0;
224     /**
225      * The Temporary Maximum Media Stream Bit Rate Request is identified by
226      * RTCP packet type value PT=RTPFB and FMT=3. RFC 5104.
227      */
228     public static final int RTPFB_TMMBR = 1 << 1;
229     /**
230      * The Temporary Maximum Media Stream Bit Rate Notification is identified
231      * by RTCP packet type value PT=RTPFB and FMT=4. RFC 5104.
232      */
233     public static final int RTPFB_TMMBN = 1 << 2;
234     /**
235      * Picture Loss Indication. The PLI FB message is identified
236      * by RTCP packet type value PT=PSFB and FMT=1. RFC 4585.
237      */
238     public static final int PSFB_PLI = 1 << 3;
239     /**
240     * Full Intra Request. The FIR message is identified by RTCP packet type
241     * value PT=PSFB and FMT=4. RFC 5104.
242     */
243     public static final int PSFB_FIR = 1 << 4;
244 
245     /** @hide */
246     @IntDef(
247         flag = true,
248         value = {
249             RTP_FB_NONE,
250             RTPFB_NACK,
251             RTPFB_TMMBR,
252             RTPFB_TMMBN,
253             PSFB_PLI,
254             PSFB_FIR,
255         })
256     @Retention(RetentionPolicy.SOURCE)
257     public @interface RtcpFbTypes {}
258 
259     private final @VideoMode int mVideoMode;
260     private final @CodecType int mCodecType;
261     private final int mFramerate;
262     private final int mBitrate;
263     private final @CodecProfile int mCodecProfile;
264     private final @CodecLevel int mCodecLevel;
265     private final int mIntraFrameIntervalSec;
266     private final int mPacketizationMode;
267     private final int mCameraId;
268     private final int mCameraZoom;
269     private final int mResolutionWidth;
270     private final int mResolutionHeight;
271     @Nullable
272     private final String mPauseImagePath;
273     private final int mDeviceOrientationDegree;
274     private final int mCvoValue;
275     private final int mMaxMtuBytes;
276     private final @RtcpFbTypes int mRtcpFbTypes;
277 
278     /** @hide */
VideoConfig(Parcel in)279     VideoConfig(Parcel in) {
280         super(RtpConfig.TYPE_VIDEO, in);
281         mVideoMode = in.readInt();
282         mCodecType = in.readInt();
283         mFramerate = in.readInt();
284         mBitrate = in.readInt();
285         mMaxMtuBytes = in.readInt();
286         mCodecProfile = in.readInt();
287         mCodecLevel = in.readInt();
288         mIntraFrameIntervalSec = in.readInt();
289         mPacketizationMode = in.readInt();
290         mCameraId = in.readInt();
291         mCameraZoom = in.readInt();
292         mResolutionWidth = in.readInt();
293         mResolutionHeight = in.readInt();
294         mPauseImagePath = in.readString();
295         mDeviceOrientationDegree = in.readInt();
296         mCvoValue = in.readInt();
297         mRtcpFbTypes = in.readInt();
298     }
299 
300     /** @hide */
VideoConfig(Builder builder)301     VideoConfig(Builder builder) {
302         super(RtpConfig.TYPE_VIDEO, builder);
303         mVideoMode = builder.mVideoMode;
304         mCodecType = builder.mCodecType;
305         mFramerate = builder.mFramerate;
306         mBitrate = builder.mBitrate;
307         mMaxMtuBytes = builder.mMaxMtuBytes;
308         mCodecProfile = builder.mCodecProfile;
309         mCodecLevel = builder.mCodecLevel;
310         mIntraFrameIntervalSec = builder.mIntraFrameIntervalSec;
311         mPacketizationMode = builder.mPacketizationMode;
312         mCameraId = builder.mCameraId;
313         mCameraZoom = builder.mCameraZoom;
314         mResolutionWidth = builder.mResolutionWidth;
315         mResolutionHeight = builder.mResolutionHeight;
316         mPauseImagePath = builder.mPauseImagePath;
317         mDeviceOrientationDegree = builder.mDeviceOrientationDegree;
318         mCvoValue = builder.mCvoValue;
319         mRtcpFbTypes = builder.mRtcpFbTypes;
320     }
321 
322     /** @hide **/
getVideoMode()323     public int getVideoMode() {
324         return this.mVideoMode;
325     }
326 
327     /** @hide **/
getCodecType()328     public int getCodecType() {
329         return this.mCodecType;
330     }
331 
332     /** @hide **/
getFramerate()333     public int getFramerate() {
334         return this.mFramerate;
335     }
336 
337     /** @hide **/
getBitrate()338     public int getBitrate() {
339         return this.mBitrate;
340     }
341 
342     /** @hide **/
getCodecProfile()343     public int getCodecProfile() {
344         return this.mCodecProfile;
345     }
346 
347     /** @hide **/
getCodecLevel()348     public int getCodecLevel() {
349         return this.mCodecLevel;
350     }
351 
352     /** @hide **/
getIntraFrameIntervalSec()353     public int getIntraFrameIntervalSec() {
354         return this.mIntraFrameIntervalSec;
355     }
356 
357     /** @hide **/
getPacketizationMode()358     public int getPacketizationMode() {
359         return this.mPacketizationMode;
360     }
361 
362     /** @hide **/
getCameraId()363     public int getCameraId() {
364         return this.mCameraId;
365     }
366 
367     /** @hide **/
getCameraZoom()368     public int getCameraZoom() {
369         return this.mCameraZoom;
370     }
371 
372     /** @hide **/
getResolutionWidth()373     public int getResolutionWidth() {
374         return this.mResolutionWidth;
375     }
376 
377     /** @hide **/
getResolutionHeight()378     public int getResolutionHeight() {
379         return this.mResolutionHeight;
380     }
381 
382     /** @hide **/
getPauseImagePath()383     public String getPauseImagePath() {
384         return this.mPauseImagePath;
385     }
386 
387     /** @hide **/
getDeviceOrientationDegree()388     public int getDeviceOrientationDegree() {
389         return this.mDeviceOrientationDegree;
390     }
391 
392     /** @hide **/
getCvoValue()393     public int getCvoValue() {
394         return this.mCvoValue;
395     }
396 
397     /** @hide **/
getRtcpFbTypes()398     public int getRtcpFbTypes() {
399         return this.mRtcpFbTypes;
400     }
401 
402     /** @hide **/
getMaxMtuBytes()403     public int getMaxMtuBytes() {
404         return mMaxMtuBytes;
405     }
406 
407     @NonNull
408     @Override
toString()409     public String toString() {
410         return super.toString() + " VideoConfig: {mVideoMode=" + mVideoMode
411             + ", mCodecType=" + mCodecType
412             + ", mFramerate=" + mFramerate
413             + ", mBitrate=" + mBitrate
414             + ", mMaxMtuBytes=" + mMaxMtuBytes
415             + ", mCodecProfile=" + mCodecProfile
416             + ", mCodecLevel=" + mCodecLevel
417             + ", mIntraFrameIntervalSec=" + mIntraFrameIntervalSec
418             + ", mPacketizationMode=" + mPacketizationMode
419             + ", mCameraId=" + mCameraId
420             + ", mCameraZoom=" + mCameraZoom
421             + ", mResolutionWidth=" + mResolutionWidth
422             + ", mResolutionHeight=" + mResolutionHeight
423             + ", mPauseImagePath=" + mPauseImagePath
424             + ", mDeviceOrientationDegree=" + mDeviceOrientationDegree
425             + ", mCvoValue=" + mCvoValue
426             + ", rtcpFb=" + mRtcpFbTypes
427             + " }";
428     }
429 
430     @Override
hashCode()431     public int hashCode() {
432         return Objects.hash(super.hashCode(), mVideoMode, mCodecType, mFramerate, mBitrate,
433             mMaxMtuBytes, mCodecProfile, mCodecLevel, mIntraFrameIntervalSec,
434             mPacketizationMode, mCameraId, mCameraZoom, mResolutionWidth, mResolutionHeight,
435             mPauseImagePath, mDeviceOrientationDegree, mCvoValue, mRtcpFbTypes);
436     }
437 
438     @Override
equals(@ullable Object o)439     public boolean equals(@Nullable Object o) {
440         if (o == null || !(o instanceof VideoConfig) || hashCode() != o.hashCode()) {
441             return false;
442         }
443 
444         if (this == o) {
445             return true;
446         }
447 
448         VideoConfig s = (VideoConfig) o;
449 
450         if (!super.equals(s)) {
451             return false;
452         }
453 
454         return (mVideoMode == s.mVideoMode
455             && mCodecType == s.mCodecType
456             && mFramerate == s.mFramerate
457             && mBitrate == s.mBitrate
458             && mMaxMtuBytes == s.mMaxMtuBytes
459             && mCodecProfile == s.mCodecProfile
460             && mCodecLevel == s.mCodecLevel
461             && mIntraFrameIntervalSec == s.mIntraFrameIntervalSec
462             && mPacketizationMode == s.mPacketizationMode
463             && mCameraId == s.mCameraId
464             && mCameraZoom == s.mCameraZoom
465             && mResolutionWidth == s.mResolutionWidth
466             && mResolutionHeight == s.mResolutionHeight
467             && Objects.equals(mPauseImagePath, s.mPauseImagePath)
468             && mDeviceOrientationDegree == s.mDeviceOrientationDegree
469             && mCvoValue == s.mCvoValue
470             && mRtcpFbTypes == s.mRtcpFbTypes);
471     }
472 
473     /**
474      * {@link Parcelable#describeContents}
475      */
describeContents()476     public int describeContents() {
477         return 0;
478     }
479 
480     /**
481      * {@link Parcelable#writeToParcel}
482      */
writeToParcel(Parcel dest, int flags)483     public void writeToParcel(Parcel dest, int flags) {
484         super.writeToParcel(dest, RtpConfig.TYPE_VIDEO);
485         dest.writeInt(mVideoMode);
486         dest.writeInt(mCodecType);
487         dest.writeInt(mFramerate);
488         dest.writeInt(mBitrate);
489         dest.writeInt(mMaxMtuBytes);
490         dest.writeInt(mCodecProfile);
491         dest.writeInt(mCodecLevel);
492         dest.writeInt(mIntraFrameIntervalSec);
493         dest.writeInt(mPacketizationMode);
494         dest.writeInt(mCameraId);
495         dest.writeInt(mCameraZoom);
496         dest.writeInt(mResolutionWidth);
497         dest.writeInt(mResolutionHeight);
498         dest.writeString(mPauseImagePath);
499         dest.writeInt(mDeviceOrientationDegree);
500         dest.writeInt(mCvoValue);
501         dest.writeInt(mRtcpFbTypes);
502     }
503 
504     public static final @NonNull Parcelable.Creator<VideoConfig>
505             CREATOR = new Parcelable.Creator() {
506                 public VideoConfig createFromParcel(Parcel in) {
507                     in.readInt();   //skip
508                     return new VideoConfig(in);
509                 }
510 
511                 public VideoConfig[] newArray(int size) {
512                     return new VideoConfig[size];
513                 }
514             };
515 
516     /**
517      * Provides a convenient way to set the fields of a {@link VideoConfig}
518      * when creating a new instance.
519      */
520     public static final class Builder extends RtpConfig.AbstractBuilder<Builder> {
521         private int mVideoMode;
522         private int mCodecType;
523         private int mFramerate;
524         private int mBitrate;
525         private int mMaxMtuBytes;
526         private int mCodecProfile;
527         private int mCodecLevel;
528         private int mIntraFrameIntervalSec;
529         private int mPacketizationMode;
530         private int mCameraId;
531         private int mCameraZoom;
532         private int mResolutionWidth;
533         private int mResolutionHeight;
534         @Nullable
535         private String mPauseImagePath;
536         private int mDeviceOrientationDegree;
537         private int mCvoValue;
538         private int mRtcpFbTypes;
539 
540         /**
541          * Default constructor for Builder.
542          */
Builder()543         public Builder() {
544         }
545 
546         @Override
self()547         Builder self() {
548             return this;
549         }
550 
551         /**
552          * Sets video mode
553          * @param videoMode video mode for preview, recording and puse image streaming
554          */
setVideoMode(final @VideoMode int videoMode)555         public Builder setVideoMode(final @VideoMode int videoMode) {
556             this.mVideoMode = videoMode;
557             return this;
558         }
559 
560         /**
561          * Sets video Codec type. It can be H.264, HEVC codec.
562          * @param codecType codec type, see {@link CodecType}
563          */
setCodecType(final @CodecType int codecType)564         public Builder setCodecType(final @CodecType int codecType) {
565             this.mCodecType = codecType;
566             return this;
567         }
568 
569         /**
570          * Sets video frame rate in encoding streaming
571          * @param framerate frame rate per second
572          */
setFramerate(final int framerate)573         public Builder setFramerate(final int framerate) {
574             this.mFramerate = framerate;
575             return this;
576         }
577 
578         /**
579          * Sets video mBitrate of encoding streaming
580          * @param bitrate mBitrate per second
581          */
setBitrate(final int bitrate)582         public Builder setBitrate(final int bitrate) {
583             this.mBitrate = bitrate;
584             return this;
585         }
586 
587         /**
588          * Sets maximum Rtp transfer unit in bytes
589          * @param maxMtuBytes bytes
590          */
setMaxMtuBytes(final int maxMtuBytes)591         public Builder setMaxMtuBytes(final int maxMtuBytes) {
592             this.mMaxMtuBytes = maxMtuBytes;
593             return self();
594         }
595 
596         /**
597          * Sets video codec encoder profile
598          * @param codecProfile codec profile, see {@link CodecProfile}
599          */
setCodecProfile(final @CodecProfile int codecProfile)600         public Builder setCodecProfile(final @CodecProfile int codecProfile) {
601             this.mCodecProfile = codecProfile;
602             return this;
603         }
604 
605         /**
606          * Sets video codec encoder level
607          * @param codecLevel codec level, see {@link CodecLevel}
608          */
setCodecLevel(final @CodecLevel int codecLevel)609         public Builder setCodecLevel(final @CodecLevel int codecLevel) {
610             this.mCodecLevel = codecLevel;
611             return this;
612         }
613 
614         /**
615          * Sets video codec encoder interval of intra-frames in seconds
616          * @param intraFrameIntervalSec interval of frame in seconds unit
617          */
setIntraFrameIntervalSec(final int intraFrameIntervalSec)618         public Builder setIntraFrameIntervalSec(final int intraFrameIntervalSec) {
619             this.mIntraFrameIntervalSec = intraFrameIntervalSec;
620             return this;
621         }
622 
623         /**
624          * Sets video Rtp packetization mode.
625          * @param packetizationMode it supports 0 and 1. 0 means Single NAL unit mode,
626          * 1 means non-interleaved mode. And Interleaved mode is not supported. Check RFC 6184.
627          */
setPacketizationMode(final int packetizationMode)628         public Builder setPacketizationMode(final int packetizationMode) {
629             this.mPacketizationMode = packetizationMode;
630             return this;
631         }
632 
633         /**
634          * Sets an identification of camera device to use for video source
635          * @param cameraId camera device identification
636          */
setCameraId(final int cameraId)637         public Builder setCameraId(final int cameraId) {
638             this.mCameraId = cameraId;
639             return this;
640         }
641 
642         /**
643          * Sets a level of zoom of camera device.
644          * @param cameraZoom zoom level, it can be 0 to 10.
645          */
setCameraZoom(final int cameraZoom)646         public Builder setCameraZoom(final int cameraZoom) {
647             this.mCameraZoom = cameraZoom;
648             return this;
649         }
650 
651         /**
652          * Sets width of resolution in transmit streaming.
653          * @param resolutionWidth width of video resolution
654          */
setResolutionWidth(final int resolutionWidth)655         public Builder setResolutionWidth(final int resolutionWidth) {
656             this.mResolutionWidth = resolutionWidth;
657             return this;
658         }
659 
660         /**
661          * Sets height of resolution in transmit streaming.
662          * @param resolutionHeight height of video resolution
663          */
setResolutionHeight(final int resolutionHeight)664         public Builder setResolutionHeight(final int resolutionHeight) {
665             this.mResolutionHeight = resolutionHeight;
666             return this;
667         }
668 
669         /**
670          * Sets path of jpg image file for video mode VIDEO_MODE_PAUSE_IMAGE.
671          * @param pauseImagePath image file path
672          */
setPauseImagePath(final String pauseImagePath)673         public Builder setPauseImagePath(final String pauseImagePath) {
674             this.mPauseImagePath = pauseImagePath;
675             return this;
676         }
677 
678         /**
679          * Sets a device orientation in degree unit captured from device sensor.
680          * @param deviceOrientationDegree degree of device orientation.
681          */
setDeviceOrientationDegree(final int deviceOrientationDegree)682         public Builder setDeviceOrientationDegree(final int deviceOrientationDegree) {
683             this.mDeviceOrientationDegree = deviceOrientationDegree;
684             return this;
685         }
686 
687         /**
688          * Sets a value to identify CVO RTP header extension id defined by the SDP negotiation.
689          * When the flag is set, MediaStack sends CVO RTP extension byte in the RTP header when the
690          * sendHeaderExtension is invoked and the Video IDR frame is sent. if this value is -1,
691          * CVO is disabled, and non zero means CVO enabled with specified offset. Check RFC 5285
692          * @param cvoValue It is the local identifier of extension. valid range is 1-14.
693          */
setCvoValue(final int cvoValue)694         public Builder setCvoValue(final int cvoValue) {
695             this.mCvoValue = cvoValue;
696             return this;
697         }
698 
699         /**
700          * Sets RTPFB, PSFB configuration with RTCP Protocol.
701          * @param rtcpFbTypes type of rtcp feedback protocols. see {@link RtcpFbTypes}
702          */
setRtcpFbTypes(final @RtcpFbTypes int rtcpFbTypes)703         public Builder setRtcpFbTypes(final @RtcpFbTypes int rtcpFbTypes) {
704             this.mRtcpFbTypes = rtcpFbTypes;
705             return this;
706         }
707 
708         /**
709          * Build the VideoConfig.
710          *
711          * @return the VideoConfig object.
712          */
build()713         public @NonNull VideoConfig build() {
714             return new VideoConfig(this);
715         }
716     }
717 }
718 
719