Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to be used with own client #87

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c886955
Update VideoStream.java
nocturnalprelude Jul 17, 2014
fb9b3d2
Update Session.java
nocturnalprelude Jul 17, 2014
e9e71d9
Allow for generating SDPs that target a user-defined port for the vid…
Jul 30, 2014
0dfda90
Update VideoStream.java
nocturnalprelude Aug 25, 2014
3e5e958
Update VideoStream.java
nocturnalprelude Aug 26, 2014
faeb192
Merge pull request #1 from nocturnalprelude/patch-1
ashyonline Oct 28, 2014
7c709af
Merge pull request #2 from nocturnalprelude/patch-2
ashyonline Oct 28, 2014
e5f3d5f
Merge pull request #3 from nocturnalprelude/patch-3
ashyonline Oct 28, 2014
1626e56
Merge pull request #4 from nocturnalprelude/patch-4
ashyonline Oct 28, 2014
a6f37a2
Merge pull request #5 from sigmabeta/custom-rtp-ports
ashyonline Oct 28, 2014
bbce4c0
Merge pull request #6 from sigmabeta/stapa-fix
ashyonline Oct 28, 2014
88e7df5
change suggested codec to MODE_MEDIACODEC_API_2
ashyonline Feb 19, 2015
ca6161d
log error to give some feedback and comment not compiling (and not us…
ashyonline Feb 19, 2015
5334d82
fixed error in the calculation of a closest supported resolution
ashyonline Feb 19, 2015
3184a7a
Check if using MediaCodec API with the buffer (not with surface) meth…
ashyonline Feb 19, 2015
7ef7a01
Video Changes
ashyonline Feb 19, 2015
4b2c666
Added constructor to SurfaceView to create a dummy surface view
ashyonline Feb 19, 2015
9280aae
added error to InvalidSurfaceException so it doesn't loose the error …
ashyonline Feb 19, 2015
c4f277b
reverted change
ashyonline Feb 19, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions src/net/majorkernelpanic/streaming/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.util.Log;

/**
* You should instantiate this class with the {@link SessionBuilder}.<br />
Expand Down Expand Up @@ -129,7 +130,7 @@ public Session() {
mOrigin = "127.0.0.1";
}

/**
/**
* The callback interface you need to implement to get some feedback
* Those will be called from the UI thread.
*/
Expand Down Expand Up @@ -369,7 +370,9 @@ public void configure() {
public void run() {
try {
syncConfigure();
} catch (Exception e) {};
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
};
}
});
}
Expand Down Expand Up @@ -622,11 +625,14 @@ public int getCamera() {

}


/**
* Toggles the LED of the phone if it has one.
* You can get the current state of the flash with
* {@link Session#getVideoTrack()} and {@link VideoStream#getFlashState()}.
**/

/*
public void toggleFlash() {
mHandler.post(new Runnable() {
@Override
Expand All @@ -642,6 +648,51 @@ public void run() {
});
}




public void setSize(final int w, final int h) {

sHandler.post(new Runnable() {

@Override
public void run() {
if (mVideoStream != null) {
try {

mVideoStream.setCameraPreviewSize(w,h);
} catch (RuntimeException e) {

}
}
}
});

}


//
public List<Size> getAvailableSizes() {

sHandler.post(new Runnable() {

@Override
public void run() {
if (mVideoStream != null) {
try {
size = mVideoStream.getSizes();
} catch (RuntimeException e) {

}
}
}
});
return size;
}

*/


/** Deletes all existing tracks & release associated resources. */
public void release() {
removeAudioTrack();
Expand Down
10 changes: 9 additions & 1 deletion src/net/majorkernelpanic/streaming/SessionBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class SessionBuilder {
private SurfaceView mSurfaceView = null;
private String mOrigin = null;
private String mDestination = null;
private int mDestinationVideoPort = 5006;
private Session.Callback mCallback = null;

// Removes the default public constructor
Expand Down Expand Up @@ -141,7 +142,7 @@ public Session build() {
video.setVideoQuality(mVideoQuality);
video.setSurfaceView(mSurfaceView);
video.setPreviewOrientation(mOrientation);
video.setDestinationPorts(5006);
video.setDestinationPorts(mDestinationVideoPort);
}

if (session.getAudioTrack()!=null) {
Expand Down Expand Up @@ -169,6 +170,13 @@ public SessionBuilder setDestination(String destination) {
return this;
}

/** Sets the destination IP & video port for the session. */
public SessionBuilder setDestination(String destination, int videoPort) {
mDestination = destination;
mDestinationVideoPort = videoPort;
return this;
}

/** Sets the origin of the session. It appears in the SDP of the session. */
public SessionBuilder setOrigin(String origin) {
mOrigin = origin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ public class InvalidSurfaceException extends RuntimeException {
public InvalidSurfaceException(String message) {
super(message);
}
public InvalidSurfaceException(String message, Throwable t) {
super(message, t);
}

}
10 changes: 8 additions & 2 deletions src/net/majorkernelpanic/streaming/gl/SurfaceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,15 @@ public SurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
mHandler = new Handler();
getHolder().addCallback(this);
}
}

public SurfaceView(Context context) {
super(context);
mHandler = new Handler();
getHolder().addCallback(this);
}

public void setAspectRatioMode(int mode) {
public void setAspectRatioMode(int mode) {
mAspectRatioMode = mode;
}

Expand Down
2 changes: 1 addition & 1 deletion src/net/majorkernelpanic/streaming/video/H264Stream.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private MP4Config testMediaCodecAPI() throws RuntimeException, IOException {
createCamera();
updateCamera();
try {
if (mQuality.resX>=640) {
if (mQuality.resX>=640 && mMode == MODE_MEDIACODEC_API) {
// Using the MediaCodec API with the buffer method for high resolutions is too slow
mMode = MODE_MEDIARECORDER_API;
}
Expand Down
4 changes: 2 additions & 2 deletions src/net/majorkernelpanic/streaming/video/VideoQuality.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public boolean equals(VideoQuality quality) {
}

public VideoQuality clone() {
return new VideoQuality(resX,resY,framerate,bitrate);
return new VideoQuality(resX,resY,framerate, bitrate);
}

public static VideoQuality parseQuality(String str) {
Expand Down Expand Up @@ -113,7 +113,7 @@ public static VideoQuality determineClosestSupportedResolution(Camera.Parameters
for (Iterator<Size> it = supportedSizes.iterator(); it.hasNext();) {
Size size = it.next();
supportedSizesStr += size.width+"x"+size.height+(it.hasNext()?", ":"");
int dist = Math.abs(quality.resX - size.width);
int dist = Math.abs(quality.resX - size.width) + Math.abs(quality.resY - size.height);
if (dist<minDist) {
minDist = dist;
v.resX = size.width;
Expand Down
Loading