StreamProfileSelector.java
Go to the documentation of this file.
1 package com.intel.realsense.camera;
2 
3 import androidx.annotation.NonNull;
4 
11 
12 import java.util.List;
13 
14 public class StreamProfileSelector implements Comparable<StreamProfileSelector> {
16  private int mWidth = 0;
17  private int mHeight = 0;
18  private int mFps = 0;
19  private boolean mEnabled;
20  private int mIndex;
21  private List<StreamProfile> mProfiles;
22 
23  public StreamProfileSelector(boolean enable, int index, List<StreamProfile> profiles)
24  {
25  mIndex = index < profiles.size() ? index : 0;
26  mEnabled = enable;
27  mProfiles = profiles;
28  }
29 
30  public boolean isEnabled() { return mEnabled; }
31 
32  public List<StreamProfile> getProfiles() { return mProfiles; }
33 
34  public int getIndex() { return mIndex; }
35 
36  public String getName(){
38  if(p.getType() == StreamType.INFRARED)
39  return p.getType().name() + "-" + p.getIndex();
40  return p.getType().name();
41  }
42 
44  if(mIndex < 0 || mIndex >= mProfiles.size())
45  return mProfiles.get(0);
46  return mProfiles.get(mIndex);
47  }
48 
51  return "";
53  return String.valueOf(vsp.getWidth()) + "x" + String.valueOf(vsp.getHeight());
54  }
55 
56  private int findIndex(StreamFormat format, int fps, int width, int height){
57  int currIndex = 0;
58  for(StreamProfile sp : mProfiles){
59  if(sp.is(Extension.VIDEO_PROFILE)) {
61  if (vsp.getFormat() == format &&
62  vsp.getWidth() == width &&
63  vsp.getHeight() == height &&
64  vsp.getFrameRate() == fps) {
65  return currIndex;
66  }
67  }
68  if(sp.is(Extension.MOTION_PROFILE)) {
70  if (msp.getFormat() == format &&
71  msp.getFrameRate() == fps) {
72  return currIndex;
73  }
74  }
75  currIndex++;
76  }
77  return -1;
78  }
79 
80  public void updateFormat(String str) {
81  mFormat = StreamFormat.valueOf(str);
82  mIndex = findIndex(mFormat, mFps, mWidth, mHeight);
83  }
84 
85  public void updateResolution(String str) {
86  mWidth = Integer.parseInt(str.split("x")[0]);
87  mHeight = Integer.parseInt(str.split("x")[1]);
88  mIndex = findIndex(mFormat, mFps, mWidth, mHeight);
89  }
90 
91  public void updateFrameRate(String str) {
92  mFps = Integer.parseInt(str);
93  mIndex = findIndex(mFormat, mFps, mWidth, mHeight);
94  }
95 
96  public void updateEnabled(boolean state) {
97  mEnabled = state;
98  mIndex = findIndex(mFormat, mFps, mWidth, mHeight);
99  }
100 
101  @Override
102  public int compareTo(@NonNull StreamProfileSelector streamProfileSelector) {
103  return getName().compareTo(streamProfileSelector.getName());
104  }
105 }
GLfloat GLfloat p
Definition: glext.h:12687
StreamProfileSelector(boolean enable, int index, List< StreamProfile > profiles)
::std_msgs::String_< std::allocator< void > > String
Definition: String.h:47
GLuint index
int compareTo(@NonNull StreamProfileSelector streamProfileSelector)
GLint GLsizei GLsizei height
GLint GLint GLsizei GLint GLenum format
GLboolean enable
Definition: glext.h:5688
int findIndex(StreamFormat format, int fps, int width, int height)
GLint GLsizei width


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:11