本文整理汇总了Java中net.majorkernelpanic.streaming.SessionBuilder类的典型用法代码示例。如果您正苦于以下问题:Java SessionBuilder类的具体用法?Java SessionBuilder怎么用?Java SessionBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SessionBuilder类属于net.majorkernelpanic.streaming包,在下文中一共展示了SessionBuilder类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildSession
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
@Override
public void buildSession() {
boolean isAudioStream = settingsPreferencesUtil.loadAudioPreference();
int videoEncoder = settingsPreferencesUtil.loadVideoEncoderPreference();
int resolution = settingsPreferencesUtil.loadResolutionPreference();
int width[] = getResources().getIntArray(R.array.resolution_width);
int height[] = getResources().getIntArray(R.array.resolution_height);
session = SessionBuilder.getInstance()
.setCallback(this)
.setSurfaceView(surfaceView)
.setPreviewOrientation(90)
.setContext(this)
.setAudioEncoder(isAudioStream ? SessionBuilder.AUDIO_AAC : SessionBuilder.AUDIO_NONE)
.setAudioQuality(new AudioQuality(16000, 32000))
.setVideoEncoder((videoEncoder == 0) ? SessionBuilder.VIDEO_H264 : SessionBuilder.VIDEO_H263)
.setVideoQuality(new VideoQuality(width[resolution], height[resolution], 20, 500000))
.build();
}
示例2: init
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
public void init() {
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this.getContext()).edit();
editor.putString(RtspServer.KEY_PORT, String.valueOf(54321));
editor.apply();
mSession = SessionBuilder.getInstance()
.setCallback(this)
.setSurfaceView(mView)
.setPreviewOrientation(90)
.setContext(this.getContext())
.setAudioEncoder(SessionBuilder.AUDIO_NONE)
.setAudioQuality(new AudioQuality(16000, 32000))
.setVideoEncoder(SessionBuilder.VIDEO_H264)
.setVideoQuality(new VideoQuality(800,480,10,500000))
.build();
mView.getHolder().addCallback(this);
this.getContext().startService(new Intent(this.getContext(),RtspServer.class));
}
示例3: onCreate
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
@Override
public void onCreate() {
// The following line triggers the initialization of ACRA
// Please do not uncomment this line unless you change the form id or I will receive your crash reports !
//ACRA.init(this);
sApplication = this;
super.onCreate();
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
notificationEnabled = settings.getBoolean("notification_enabled", true);
// On android 3.* AAC ADTS is not supported so we set the default encoder to AMR-NB, on android 4.* AAC is the default encoder
audioEncoder = (Integer.parseInt(android.os.Build.VERSION.SDK)<14) ? SessionBuilder.AUDIO_AMRNB : SessionBuilder.AUDIO_AAC;
audioEncoder = Integer.parseInt(settings.getString("audio_encoder", String.valueOf(audioEncoder)));
videoEncoder = Integer.parseInt(settings.getString("video_encoder", String.valueOf(videoEncoder)));
// Read video quality settings from the preferences
videoQuality = new VideoQuality(
settings.getInt("video_resX", videoQuality.resX),
settings.getInt("video_resY", videoQuality.resY),
Integer.parseInt(settings.getString("video_framerate", String.valueOf(videoQuality.framerate))),
Integer.parseInt(settings.getString("video_bitrate", String.valueOf(videoQuality.bitrate/1000)))*1000);
SessionBuilder.getInstance()
.setContext(getApplicationContext())
.setAudioEncoder(!settings.getBoolean("stream_audio", true)?0:audioEncoder)
.setVideoEncoder(!settings.getBoolean("stream_video", false)?0:videoEncoder)
.setVideoQuality(videoQuality);
// Listens to changes of preferences
settings.registerOnSharedPreferenceChangeListener(mOnSharedPreferenceChangeListener);
registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}
示例4: onSharedPreferenceChanged
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals("video_resX") || key.equals("video_resY")) {
videoQuality.resX = sharedPreferences.getInt("video_resX", 0);
videoQuality.resY = sharedPreferences.getInt("video_resY", 0);
}
else if (key.equals("video_framerate")) {
videoQuality.framerate = Integer.parseInt(sharedPreferences.getString("video_framerate", "0"));
}
else if (key.equals("video_bitrate")) {
videoQuality.bitrate = Integer.parseInt(sharedPreferences.getString("video_bitrate", "0"))*1000;
}
else if (key.equals("audio_encoder") || key.equals("stream_audio")) {
audioEncoder = Integer.parseInt(sharedPreferences.getString("audio_encoder", String.valueOf(audioEncoder)));
SessionBuilder.getInstance().setAudioEncoder( audioEncoder );
if (!sharedPreferences.getBoolean("stream_audio", false))
SessionBuilder.getInstance().setAudioEncoder(0);
}
else if (key.equals("stream_video") || key.equals("video_encoder")) {
videoEncoder = Integer.parseInt(sharedPreferences.getString("video_encoder", String.valueOf(videoEncoder)));
SessionBuilder.getInstance().setVideoEncoder( videoEncoder );
if (!sharedPreferences.getBoolean("stream_video", true))
SessionBuilder.getInstance().setVideoEncoder(0);
}
else if (key.equals("notification_enabled")) {
notificationEnabled = sharedPreferences.getBoolean("notification_enabled", true);
}
}
示例5: initRtspClient
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
private void initRtspClient() {
// Configures the SessionBuilder
mSession = SessionBuilder.getInstance()
.setContext(getApplicationContext())
.setAudioEncoder(SessionBuilder.AUDIO_AAC)
.setAudioQuality(new AudioQuality(8000, 16000))
.setVideoQuality(new VideoQuality(UVCCamera.DEFAULT_PREVIEW_WIDTH * 2, UVCCamera.DEFAULT_PREVIEW_HEIGHT, SELECTED_FPS, 400000))
.setVideoEncoder(SessionBuilder.VIDEO_H264)
.setPreviewOrientation(90)
.setSurfaceView(mSurfaceView)
.setCallback(this).build();
// Get Surface
canvasSurface = mSession.getVideoTrack().getSurface();
// Configures the RTSP client
mClient = new RtspClient();
mClient.setSession(mSession);
mClient.setCallback(this);
mSurfaceView.setAspectRatioMode(SurfaceView.ASPECT_RATIO_PREVIEW);
String ip, port, path;
// We parse the URI written in the Editext
Pattern uri = Pattern.compile("rtsp://(.+):(\\d+)/(.+)");
Matcher m = uri.matcher(AppConfig.STREAM_URL);
m.find();
ip = m.group(1);
port = m.group(2);
path = m.group(3);
mClient.setCredentials(AppConfig.PUBLISHER_USERNAME,
AppConfig.PUBLISHER_PASSWORD);
mClient.setServerAddress(ip, Integer.parseInt(port));
mClient.setStreamPath("/" + path);
Log.e(TAG, "done initRtsp");
}
示例6: initRtspClient
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
private void initRtspClient() {
// Configures the SessionBuilder
mSession = SessionBuilder.getInstance()
.setContext(getApplicationContext())
.setAudioEncoder(SessionBuilder.AUDIO_NONE)
.setAudioQuality(new AudioQuality(8000, 16000))
.setVideoQuality(new VideoQuality(640, 480, 15, 200000))
.setVideoEncoder(SessionBuilder.VIDEO_H264)
.setSurfaceView(mSurfaceView)
.setPreviewOrientation(90)
.setCallback(this).build();
// Configures the RTSP client
mClient = new RtspClient();
mClient.setSession(mSession);
mClient.setCallback(this);
mSurfaceView.setAspectRatioMode(SurfaceView.ASPECT_RATIO_PREVIEW);
String ip, port, path;
// We parse the URI written in the Editext
Pattern uri = Pattern.compile("rtsp://(.+):(\\d+)/(.+)");
Matcher m = uri.matcher(AppConfig.STREAM_URL);
m.find();
ip = m.group(1);
port = m.group(2);
path = m.group(3);
mClient.setCredentials(AppConfig.PUBLISHER_USERNAME,
AppConfig.PUBLISHER_PASSWORD);
mClient.setServerAddress(ip, Integer.parseInt(port));
mClient.setStreamPath("/" + path);
}
示例7: initRtspClient
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
private void initRtspClient() {
// Configures the SessionBuilder
mSession = SessionBuilder.getInstance()
.setContext(getApplicationContext())
.setAudioEncoder(SessionBuilder.AUDIO_NONE)
.setAudioQuality(new AudioQuality(8000, 16000))
.setVideoQuality(new VideoQuality(640, 480, 15, 200000))
.setVideoEncoder(SessionBuilder.VIDEO_H264)
.setPreviewOrientation(90)
.setSurfaceView(mSurfaceView)
.setCallback(this).build();
// Get Surface
canvasSurface = mSession.getVideoTrack().getSurface();
// Configures the RTSP client
mClient = new RtspClient();
mClient.setSession(mSession);
mClient.setCallback(this);
mSurfaceView.setAspectRatioMode(SurfaceView.ASPECT_RATIO_PREVIEW);
String ip, port, path;
// We parse the URI written in the Editext
Pattern uri = Pattern.compile("rtsp://(.+):(\\d+)/(.+)");
Matcher m = uri.matcher(AppConfig.STREAM_URL);
m.find();
ip = m.group(1);
port = m.group(2);
path = m.group(3);
mClient.setCredentials(AppConfig.PUBLISHER_USERNAME,
AppConfig.PUBLISHER_PASSWORD);
mClient.setServerAddress(ip, Integer.parseInt(port));
mClient.setStreamPath("/" + path);
Log.e(TAG, "done initRtsp");
}
示例8: onCreate
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mApplication = (SpydroidApplication) getApplication();
setContentView(R.layout.gwidi);
if (findViewById(R.id.handset_pager) != null) {
// Handset detected !
mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.handset_pager);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mSurfaceView = (SurfaceView)findViewById(R.id.handset_camera_view);
SessionBuilder.getInstance().setSurfaceView(mSurfaceView);
SessionBuilder.getInstance().setPreviewOrientation(90);
} else {
// Tablet detected !
device = TABLET;
mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.tablet_pager);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
SessionBuilder.getInstance().setPreviewOrientation(0);
}
mViewPager.setAdapter(mAdapter);
// Remove the ads if this is the donate version of the app.
if (mApplication.DONATE_VERSION) {
((LinearLayout)findViewById(R.id.adcontainer)).removeAllViews();
}
// Prevents the phone from going to sleep mode
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "net.majorkernelpanic.spydroid.wakelock");
// Starts the service of the HTTP server
this.startService(new Intent(this,CustomHttpServer.class));
// Starts the service of the RTSP server
this.startService(new Intent(this,CustomRtspServer.class));
}
示例9: onCreate
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
/** Called with the activity is first created. */
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
// setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
requestWindowFeature(Window.FEATURE_PROGRESS);
setScreenOnFlag();
setContentView(R.layout.video_camera);
// findViewById需要在setContentView之后,否则获得为null
ImageButton stopButton = (ImageButton) findViewById(R.id.camera_stop);
ImageButton switchButton = (ImageButton) findViewById(R.id.camera_switch);
ImageButton muteButton = (ImageButton) findViewById(R.id.camera_mute);
WindowManager windowManager = (WindowManager) this
.getSystemService(WINDOW_SERVICE);
int screenWidth = windowManager.getDefaultDisplay().getWidth();
int screenHeight = windowManager.getDefaultDisplay().getHeight();
stopButton.setLayoutParams(new LinearLayout.LayoutParams(
screenWidth / 2, screenHeight / 10));
switchButton.setLayoutParams(new LinearLayout.LayoutParams(
screenWidth / 4, screenHeight / 10));
muteButton.setLayoutParams(new LinearLayout.LayoutParams(
screenWidth / 4, screenHeight / 10));
// mVideoPreview = (VideoPreview) findViewById(R.id.camera_preview);
// mVideoPreview.setAspectRatio(VIDEO_ASPECT_RATIO);
mSurfaceView = (SurfaceView)findViewById(R.id.camera_preview);
// don't set mSurfaceHolder here. We have it set ONLY within
// surfaceCreated / surfaceDestroyed, other parts of the code
// assume that when it is set, the surface is also set.
// SurfaceHolder holder = mVideoPreview.getHolder();
SurfaceHolder holder = mSurfaceView.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mRecordingTimeView = (TextView) findViewById(R.id.recording_time);
mFPS = (TextView) findViewById(R.id.fps);
mVideoFrame = (VideoView) findViewById(R.id.video_frame);
// Sets the port of the RTSP server to 1234
Editor editor = PreferenceManager.getDefaultSharedPreferences(this)
.edit();
editor.putString(RtspServer.KEY_PORT, String.valueOf(1234));
editor.commit();
// Configures the SessionBuilder
SessionBuilder.getInstance().setSurfaceView(mSurfaceView)
.setPreviewOrientation(90).setContext(getApplicationContext())
.setAudioEncoder(SessionBuilder.AUDIO_NONE)
.setVideoEncoder(SessionBuilder.VIDEO_H264);
// Starts the RTSP server
this.startService(new Intent(this, RtspServer.class));
}
示例10: onCreate
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mApplication = (SpydroidApplication) getApplication();
setContentView(R.layout.spydroid);
if (findViewById(R.id.handset_pager) != null) {
// Handset detected !
mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.handset_pager);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mSurfaceView = (SurfaceView)findViewById(R.id.handset_camera_view);
SessionBuilder.getInstance().setSurfaceView(mSurfaceView);
SessionBuilder.getInstance().setPreviewOrientation(90);
} else {
// Tablet detected !
device = TABLET;
mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.tablet_pager);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
SessionBuilder.getInstance().setPreviewOrientation(0);
}
mViewPager.setAdapter(mAdapter);
// Remove the ads if this is the donate version of the app.
if (mApplication.DONATE_VERSION) {
((LinearLayout)findViewById(R.id.adcontainer)).removeAllViews();
}
// Prevents the phone from going to sleep mode
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "net.majorkernelpanic.spydroid.wakelock");
// Starts the service of the HTTP server
this.startService(new Intent(this,CustomHttpServer.class));
// Starts the service of the RTSP server
this.startService(new Intent(this,CustomRtspServer.class));
}
示例11: onCreateView
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.preview,container,false);
mTextView = (TextView)rootView.findViewById(R.id.tooltip);
if (((SpydroidActivity)getActivity()).device == ((SpydroidActivity)getActivity()).TABLET) {
mSurfaceView = (SurfaceView)rootView.findViewById(R.id.tablet_camera_view);
mSurfaceHolder = mSurfaceView.getHolder();
// We still need this line for backward compatibility reasons with android 2
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
SessionBuilder.getInstance().setSurfaceHolder(mSurfaceHolder);
}
return rootView;
}
示例12: onCreate
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mApplication = (SpydroidApplication) getApplication();
setContentView(R.layout.spydroid);
if (findViewById(R.id.handset_pager) != null) {
// Handset detected !
mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.handset_pager);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mSurfaceView = (SurfaceView)findViewById(R.id.handset_camera_view);
mSurfaceHolder = mSurfaceView.getHolder();
// We still need this line for backward compatibility reasons with android 2
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
SessionBuilder.getInstance().setSurfaceHolder(mSurfaceHolder);
} else {
// Tablet detected !
device = TABLET;
mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.tablet_pager);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
mApplication.videoQuality.orientation = 0;
}
mViewPager.setAdapter(mAdapter);
// Remove the ads if this is the donate version of the app.
if (mApplication.DONATE_VERSION) {
((LinearLayout)findViewById(R.id.adcontainer)).removeAllViews();
}
// Prevents the phone from going to sleep mode
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "net.majorkernelpanic.spydroid.wakelock");
// Starts the service of the HTTP server
this.startService(new Intent(this,CustomHttpServer.class));
// Starts the service of the RTSP server
this.startService(new Intent(this,CustomRtspServer.class));
}
示例13: onCreate
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
@Override
public void onCreate() {
// The following line triggers the initialization of ACRA
// Please do not uncomment this line unless you change the form id or I will receive your crash reports !
//ACRA.init(this);
sApplication = this;
super.onCreate();
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
notificationEnabled = settings.getBoolean("notification_enabled", true);
// On android 3.* AAC ADTS is not supported so we set the default encoder to AMR-NB, on android 4.* AAC is the default encoder
audioEncoder = (Integer.parseInt(android.os.Build.VERSION.SDK)<14) ? SessionBuilder.AUDIO_AMRNB : SessionBuilder.AUDIO_AAC;
audioEncoder = Integer.parseInt(settings.getString("audio_encoder", String.valueOf(audioEncoder)));
videoEncoder = Integer.parseInt(settings.getString("video_encoder", String.valueOf(videoEncoder)));
// Read video quality settings from the preferences
videoQuality = VideoQuality.merge(
new VideoQuality(
settings.getInt("video_resX", 0),
settings.getInt("video_resY", 0),
Integer.parseInt(settings.getString("video_framerate", "0")),
Integer.parseInt(settings.getString("video_bitrate", "0"))*1000),
videoQuality);
SessionBuilder.getInstance()
.setContext(getApplicationContext())
.setAudioEncoder(!settings.getBoolean("stream_audio", true)?0:audioEncoder)
.setVideoEncoder(!settings.getBoolean("stream_video", false)?0:videoEncoder)
.setHeartEncoder(!settings.getBoolean("stream_heartrate", false)?0:heartRateEncoder)
.setVideoQuality(videoQuality);
// Listens to changes of preferences
settings.registerOnSharedPreferenceChangeListener(mOnSharedPreferenceChangeListener);
registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
}
示例14: onCreateView
import net.majorkernelpanic.streaming.SessionBuilder; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.preview,container,false);
mTextView = (TextView)rootView.findViewById(R.id.tooltip);
if (((SpydroidActivity)getActivity()).device == ((SpydroidActivity)getActivity()).TABLET) {
mSurfaceView = (SurfaceView)rootView.findViewById(R.id.tablet_camera_view);
SessionBuilder.getInstance().setSurfaceView(mSurfaceView);
}
return rootView;
}