straw/app/src/main/java/us/shandian/giga/postprocessing/WebMMuxer.java
kapodamy 5825843f68 main commit
Post-processing infrastructure
* remove interfaces with one implementation
* fix download resources with unknow length
* marquee style for ProgressDrawable
* "view details" option in mission context menu
* notification for finished downloads
* postprocessing infrastructure: sub-missions, circular file, layers for layers of abstractions for Java IO streams
* Mp4 muxing (only DASH brand)
* WebM muxing
* Captions downloading
* alert dialog for overwrite existing downloads finished or not.

Misc changes
* delete SQLiteDownloadDataSource.java
* delete DownloadMissionSQLiteHelper.java
* implement Localization from #114

Misc fixes (this branch)
* restore old mission listeners variables. Prevents registered listeners get de-referenced on low-end devices
* DownloadManagerService.checkForRunningMission() now return false if the mission has a error.
* use Intent.FLAG_ACTIVITY_NEW_TASK when launching an activity from gigaget threads (apparently it is required in old versions of android)

More changes
* proper error handling "infrastructure"
* queue instead of multiple downloads
* move serialized pending downloads (.giga files) to app data
* stop downloads when swicthing to mobile network (never works, see 2nd point)
* save the thread count for next downloads
* a lot of incoherences fixed
* delete DownloadManagerTest.java (too many changes to keep this file updated)
2018-11-08 19:00:44 -03:00

44 lines
1.3 KiB
Java

package us.shandian.giga.postprocessing;
import org.schabi.newpipe.extractor.utils.WebMReader.TrackKind;
import org.schabi.newpipe.extractor.utils.WebMReader.WebMTrack;
import org.schabi.newpipe.extractor.utils.WebMWriter;
import org.schabi.newpipe.extractor.utils.io.SharpStream;
import java.io.IOException;
import us.shandian.giga.get.DownloadMission;
/**
* @author kapodamy
*/
class WebMMuxer extends Postprocessing {
WebMMuxer(DownloadMission mission) {
super(mission);
recommendedReserve = (1024 + 512) * 1024;// 1.50 MiB
worksOnSameFile = true;
}
@Override
int process(SharpStream out, SharpStream... sources) throws IOException {
WebMWriter muxer = new WebMWriter(sources);
muxer.parseSources();
// youtube uses a webm with a fake video track that acts as a "cover image"
WebMTrack[] tracks = muxer.getTracksFromSource(1);
int audioTrackIndex = 0;
for (int i = 0; i < tracks.length; i++) {
if (tracks[i].kind == TrackKind.Audio) {
audioTrackIndex = i;
break;
}
}
muxer.selectTracks(0, audioTrackIndex);
muxer.build(out);
return OK_RESULT;
}
}