-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
424 additions
and
181 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.hd.screen.capture; | ||
|
||
import android.app.Application; | ||
|
||
import com.squareup.leakcanary.LeakCanary; | ||
|
||
|
||
/** | ||
* Created by hd on 2018/5/23 . | ||
*/ | ||
public class CaptureApp extends Application { | ||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
if (LeakCanary.isInAnalyzerProcess(this)) { | ||
// This process is dedicated to LeakCanary for heap analysis. | ||
// You should not init your app in this process. | ||
return; | ||
} | ||
LeakCanary.install(this); | ||
// Normal app init code... | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.hd.screen.capture; | ||
|
||
import android.media.MediaCodecInfo; | ||
import android.util.Log; | ||
import android.util.Range; | ||
|
||
import com.hd.screencapture.config.AudioConfig; | ||
import com.hd.screencapture.config.VideoConfig; | ||
import com.hd.screencapture.help.Utils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by hd on 2018/5/23 . | ||
*/ | ||
public final class LogConfig { | ||
|
||
/** | ||
* when you don't understand how to use config{@link VideoConfig}{@link AudioConfig}, | ||
* maybe these parameters can help you. | ||
*/ | ||
public static void log() { | ||
MediaCodecInfo[] videoInfos = Utils.findAllVideoEncoder(); | ||
MediaCodecInfo[] audioInfos = Utils.findAllAudioEncoder(); | ||
String[] videoCodecName = Utils.findAllVideoCodecName(); | ||
String[] audioCodecName = Utils.findAllAudioCodecName(); | ||
Log.d("tag", "\nall ========" + Arrays.toString(videoInfos)// | ||
+ "\n========" + Arrays.toString(audioInfos)// | ||
+ "\n========" + Arrays.toString(videoCodecName)// | ||
+ "\n========" + Arrays.toString(audioCodecName)// | ||
+ "\n========" + Arrays.toString(Utils.aacProfiles())); | ||
for (String codecName : videoCodecName) { | ||
MediaCodecInfo.CodecProfileLevel[] levels = Utils.findVideoProfileLevel(codecName); | ||
MediaCodecInfo.CodecCapabilities capabilities = Utils.findVideoCodecCapabilities(codecName); | ||
for (MediaCodecInfo.CodecProfileLevel level : levels) { | ||
Log.d("tag", "\nvideoCodecName : " + codecName + " ,level========" + level.level // | ||
+ "\n========" + level.profile // | ||
+ "\n========" + Utils.avcProfileLevelToString(level)// | ||
+ "\n========" + Utils.toProfileLevel(Utils.avcProfileLevelToString(level))); | ||
} | ||
Range<Integer> videoBitrateRange = capabilities.getVideoCapabilities().getBitrateRange(); | ||
Range<Integer> videoFrameRatesRange = capabilities.getVideoCapabilities().getSupportedFrameRates(); | ||
|
||
Log.d("tag", "\nvideoCodecName : " + codecName + "=======" + videoBitrateRange// | ||
+ "\n========" + videoFrameRatesRange); | ||
|
||
int[] videoColorFormats = capabilities.colorFormats; | ||
Log.d("tag", "\nvideoCodecName : " + codecName + "==videoColorFormats:" + Arrays.toString(videoColorFormats)); | ||
for (int colorFormat : videoColorFormats) { | ||
Log.d("tag", "\nvideoCodecName : " + codecName // | ||
+ "\n=======colorFormat :" + Utils.toHumanReadable(colorFormat)// | ||
+ "\n=======" + Utils.toColorFormat(Utils.toHumanReadable(colorFormat))); | ||
} | ||
} | ||
for (String codecName : audioCodecName) { | ||
MediaCodecInfo.CodecProfileLevel[] levels = Utils.findAudioProfileLevel(codecName); | ||
MediaCodecInfo.CodecCapabilities capabilities = Utils.findAudioCodecCapabilities(codecName); | ||
for (MediaCodecInfo.CodecProfileLevel level : levels) { | ||
Log.d("tag", "\naudioCodecName : " + codecName + " ,level========" + level.level // | ||
+ "\n========" + level.profile); | ||
} | ||
Range<Integer> audioBitrateRange = capabilities.getAudioCapabilities().getBitrateRange(); | ||
Range<Integer>[] audioSampleRateRanges = capabilities.getAudioCapabilities().getSupportedSampleRateRanges(); | ||
int[] audioSampleRates = capabilities.getAudioCapabilities().getSupportedSampleRates(); | ||
|
||
// | ||
int lower = Math.max(audioBitrateRange.getLower() / 1000, 80); | ||
int upper = audioBitrateRange.getUpper() / 1000; | ||
List<Integer> rates = new ArrayList<>(); | ||
for (int rate = lower; rate < upper; rate += lower) { | ||
rates.add(rate); | ||
} | ||
rates.add(upper); | ||
|
||
Log.d("tag", "\naudioCodecName : " + codecName + "=======" + audioBitrateRange // | ||
+ "\n========" + rates// | ||
+ "\n========" + Arrays.toString(audioSampleRateRanges) // | ||
+ "\n========" + Arrays.toString(audioSampleRates)); | ||
|
||
|
||
int[] audioColorFormats = capabilities.colorFormats; | ||
Log.d("tag", "\naudioCodecName : " + codecName + "==audioColorFormats:" + Arrays.toString(audioColorFormats)); | ||
for (int colorFormat : audioColorFormats) { | ||
Log.d("tag", "\naudioCodecName : " + codecName// | ||
+ "\n=======colorFormat :" + Utils.toHumanReadable(colorFormat)// | ||
+ "\n=======" + Utils.toColorFormat(Utils.toHumanReadable(colorFormat))); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
app/src/main/java/com/hd/screen/capture/ScreenCapturePresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.hd.screen.capture; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.NonNull; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.widget.Toast; | ||
|
||
import com.hd.screencapture.ScreenCapture; | ||
import com.hd.screencapture.callback.ScreenCaptureStreamCallback; | ||
import com.hd.screencapture.config.ScreenCaptureConfig; | ||
import com.hd.screencapture.config.VideoConfig; | ||
|
||
/** | ||
* Created by hd on 2018/5/23 . | ||
*/ | ||
public class ScreenCapturePresenter { | ||
|
||
private ScreenCapture screenCapture; | ||
|
||
private Context context; | ||
|
||
ScreenCapturePresenter(@NonNull AppCompatActivity activity) { | ||
this.context=activity.getApplicationContext(); | ||
initCapture(activity); | ||
} | ||
|
||
private void initCapture(AppCompatActivity activity) { | ||
ScreenCaptureConfig captureConfig = new ScreenCaptureConfig.Builder()// | ||
.setAllowLog(BuildConfig.DEBUG)// | ||
.setVideoConfig(VideoConfig.initDefaultConfig(activity))// | ||
//not completed | ||
//.setAudioConfig(AudioConfig.initDefaultConfig())// | ||
.setCaptureCallback((ScreenCaptureStreamCallback) activity)// | ||
.setAutoMoveTaskToBack(true)// | ||
.create();// | ||
screenCapture = ScreenCapture.with(activity).setConfig(captureConfig); | ||
} | ||
|
||
public void startCapture() { | ||
if (!screenCapture.isRunning()) { | ||
screenCapture.startCapture(); | ||
} else { | ||
Toast.makeText(context, "current is capturing state", Toast.LENGTH_SHORT).show(); | ||
} | ||
} | ||
|
||
public void stopCapture() { | ||
if (screenCapture.isRunning()) { | ||
screenCapture.stopCapture(); | ||
} else { | ||
Toast.makeText(context, "current is stopped state", Toast.LENGTH_SHORT).show(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.