SandBox/Pavel: natives.patch
File natives.patch, 14.2 KB (added by pap, 15 years ago) |
---|
-
sophie2-platform/modules/org.sophie2.main.media.natlib/src/test/java/org/sophie2/main/media/natlib/demo/AudioDemo.java
Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
16 16 import javax.swing.SwingUtilities; 17 17 18 18 import org.sophie2.base.commons.util.ImmImage; 19 import org.sophie2.base.commons.util.bindata.RawBinData; 19 import org.sophie2.base.commons.util.bindata.BinData; 20 import org.sophie2.base.commons.util.bindata.FileBinData; 20 21 import org.sophie2.base.media.AudioChunk; 21 22 import org.sophie2.base.media.BaseMediaModule; 22 23 import org.sophie2.base.media.MediaComposite; … … 42 43 @SuppressWarnings("serial") 43 44 public class AudioDemo extends Component { 44 45 45 private RawBinData binData;46 private BinData binData; 46 47 private int time = 0; 47 48 48 private MediaHandler handler; 49 private MediaHandler audioHandler; 50 private MediaHandler videoHandler; 49 51 private final MediaInfo info; 50 52 51 53 @Override 52 54 public void paint(Graphics g) { 53 if (this.get Handler().getInfo().getDimensions().getHeight() > 054 && this.get Handler().getInfo().getDimensions().getWidth() > 0) {55 if (this.getVideoHandler().getInfo().getDimensions().getHeight() > 0 56 && this.getVideoHandler().getInfo().getDimensions().getWidth() > 0) { 55 57 ImmImage img; 56 58 //SophieLog.debug(this.time); 57 59 try { 58 img = this. handler.getFrame(this.time);60 img = this.videoHandler.getFrame(this.time); 59 61 } catch (RuntimeException e) { 60 62 img = new ImmImage(new BufferedImage((int) this.info 61 63 .getDimensions().getWidth(),(int) this.info.getDimensions() … … 75 77 * @throws IOException 76 78 */ 77 79 public AudioDemo(String file) throws IOException { 78 this.binData = new RawBinData(new File(file)); 79 this.handler = new NativeMediaHandler(this.binData); 80 this.info = this.getHandler().getInfo(); 80 this.binData = FileBinData.create(new File(file)); 81 this.audioHandler = new NativeMediaHandler(this.binData); 82 this.videoHandler = new NativeMediaHandler(this.binData); 83 this.info = this.getAudioHandler().getInfo(); 81 84 } 82 85 83 86 /** … … 103 106 * the specific media file. 104 107 */ 105 108 protected void stop() { 106 this.getHandler().dispose(); 107 this.handler = null; 109 this.getAudioHandler().dispose(); 110 this.getVideoHandler().dispose(); 111 this.audioHandler = null; 112 this.videoHandler = null; 108 113 } 109 114 110 115 /** … … 120 125 * starts at <tt>millis</tt>. 121 126 */ 122 127 protected AudioChunk getAudio(int millis) { 123 AudioChunk audio = this.get Handler().getAudio(millis);128 AudioChunk audio = this.getAudioHandler().getAudio(millis); 124 129 return audio; 125 130 } 126 131 … … 143 148 // String path = "/home/stefan/Desktop/41_30secMP3pro-64.mp3"; 144 149 // String path = "/home/stefan/Desktop/93613 (copy).mpg"; 145 150 //String path = "/home/pavel/Desktop/6jfzqz42iz0i2u3jwwx2ax1ts.mov"; 146 // String path = "/home/stefan/media samples/soxmas_s.mov";147 151 //String path = "/home/milo/Desktop/07 - The Mirror.mp3"; 148 152 // String path = "/home/stefan/11k16bitpcm.wav"; 149 153 //String path = "/home/stefan/media samples/media samples/41_30secMP3pro-64.wav"; … … 162 166 // path += "Umbro Commercial.avi"; 163 167 //audio 164 168 165 String path = "/home/stefan/Desktop/Audio/";166 path += "Autotamponneuse.ogg";169 //String path = "/home/stefan/Desktop/Audio/"; 170 //path += "Autotamponneuse.ogg"; 167 171 // path += "Bugs Bunny.wav"; 168 172 // String path = "/home/stefan/Desktop/tempFile15139tempFile44832tempFile26989tempFile26966CanadaGeese.wav"; 169 173 174 //String path = "/home/pavel/Desktop/res/carcass - swansong - 03 - blackstar.mp3"; 175 // String path = "/home/pavel/Desktop/res/two.divx6.avi"; 176 // String path = "/media/other/Music/Marduk/1999 - Panzer Division Marduk/01 - Marduk - Panzer Division Marduk.mp3"; 177 // String path = "/home/pavel/Desktop/res/alice in chains - junkhead-singlesreleaseparty.mpg"; 178 //String path = "/home/pavel/Desktop/res/02 - Hype! (bonus performances).avi"; 179 // String path = "/home/pavel/Desktop/res/8uksomunz336d4ai7414zfhkx.mov"; 180 // String path = "/home/pavel/Desktop/res/6jfzqz42iz0i2u3jwwx2ax1ts.mov"; 181 String path = "/home/pavel/Desktop/res/ulica_sezam_mana_mana_vbox7.avi"; 170 182 171 183 final AudioDemo audioDemo = new AudioDemo(path); 172 184 final NativeAudioOutput output = new NativeAudioOutput(); … … 204 216 } 205 217 206 218 int localTime(TimePos time) { 207 double d = audioDemo.get Handler().getInfo()219 double d = audioDemo.getAudioHandler().getInfo() 208 220 .getDuration(); 209 221 int hundreds = (int) (d * 100) - 1; 210 222 return (int) (time.getMillis() / 10 % hundreds) * 10; … … 224 236 * 225 237 * @return current demo's {@link MediaHandler}. 226 238 */ 227 public MediaHandler getHandler() {228 return this. handler;239 MediaHandler getVideoHandler() { 240 return this.videoHandler; 229 241 } 242 243 /** 244 * Getter for {@link MediaHandler} that is contained in the demo. 245 * 246 * @return current demo's {@link MediaHandler}. 247 */ 248 MediaHandler getAudioHandler() { 249 return this.audioHandler; 250 } 251 230 252 } 253 No newline at end of file -
sophie2-platform/modules/org.sophie2.main.media.natlib/src/test/java/org/sophie2/main/media/natlib/demo/VideoDemo.java
13 13 import javax.swing.SwingUtilities; 14 14 15 15 import org.sophie2.base.commons.util.ImmImage; 16 import org.sophie2.base.commons.util.bindata.RawBinData; 16 import org.sophie2.base.commons.util.bindata.BinData; 17 import org.sophie2.base.commons.util.bindata.FileBinData; 17 18 import org.sophie2.base.media.MediaHandler; 18 19 import org.sophie2.base.media.MediaInfo; 19 20 import org.sophie2.base.natlib.BaseNatlibModule; … … 35 36 */ 36 37 private static final long serialVersionUID = 1L; 37 38 38 private RawBinData binData;39 private BinData binData; 39 40 private int time = 0; 40 41 41 42 private MediaHandler handler; … … 54 55 * @throws IOException on io error. 55 56 */ 56 57 public VideoDemo(String fileToOpen) throws IOException { 57 this.binData = new RawBinData(new File(fileToOpen));58 this.binData = FileBinData.create(new File(fileToOpen)); 58 59 this.handler = new NativeMediaHandler(this.binData); 59 60 this.info = this.handler.getInfo(); 60 61 } -
sophie2-platform/modules/org.sophie2.main.func.media/src/main/java/org/sophie2/main/func/media/MediaImportManager.java
69 69 ImportBinDataType importTyppe = 70 70 ((Map<File, ImportBinDataType>) additionalData).get(resFile); 71 71 72 assert importTyppe != null;72 //assert importTyppe != null; 73 73 74 if (importTyppe == null) { 75 importTyppe = ImportBinDataType.LINK; 76 } 77 74 78 try { 75 79 if (importTyppe == ImportBinDataType.EMBED) { 76 80 media = new RawBinData(resFile); -
sophie2-platform/modules/org.sophie2.dev/src/main/java/org/sophie2/dev/author/FakeAuthorMain.java
102 102 //SophieLog.setMinLevel("org.sophie2.base.model.resources.r4", LogLevel.DEBUG); 103 103 //SophieLog.setMinLevel("org.sophie2.base.model.resources.r4.access", LogLevel.INFO); 104 104 //SophieLog.setMinLevel("org.sophie2.main.media", LogLevel.ALL); 105 SophieLog.setMinLevel("org.sophie2.main.media.natlib", LogLevel.NONE);106 SophieLog.setMinLevel("org.sophie2.base.natlib", LogLevel.NONE);105 //SophieLog.setMinLevel("org.sophie2.main.media.natlib", LogLevel.ALL); 106 //SophieLog.setMinLevel("org.sophie2.base.natlib", LogLevel.ALL); 107 107 //SophieLog.setMinLevel("org.sophie2.main.func.timelines", LogLevel.DEBUG); 108 108 //SophieLog.setMinLevel("org.sophie2.main.func.media.view", LogLevel.ALL); 109 109 //SophieLog.setMinLevel("org.sophie2.base.bound", LogLevel.ALL); -
sophie2-platform/modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/dialogs/BookPropertiesDialog.java
210 210 if (this.input.getHasLoopedPages()) { 211 211 Response response = DialogManager.get().showDialog( 212 212 BINDING_INPUT_WITH_LOOPED_PAGES); 213 if ( response.equals(Response.CANCEL)) {213 if (Response.CANCEL.equals(response)) { 214 214 getBindAudioToPagesCheck().setSelected(false); 215 215 } 216 216 } else { -
sophie2-platform/modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/book/BookView.java
166 166 getPageView(curPage).setTime(newState.getPageTime()); 167 167 } 168 168 169 private TimePos getPageTime(TimelineOptions pageOptions, 170 TimePos oldPageTime, long distance) { 169 private TimePos getPageTime(TimelineOptions pageOptions, TimePos oldPageTime, long distance) { 171 170 boolean sync = model().get().getSyncAudioToPages(); 172 171 173 172 return sync ? pageOptions.setLooped(false).advance(oldPageTime, distance) : -
sophie2-native/src/media_decoder/media_decoder.h
26 26 static const int CHUNK_BYTES = CHUNK_SAMPLES * 4; 27 27 static const int BUFFER_SIZE = (AVCODEC_MAX_AUDIO_FRAME_SIZE * 6) / 2; 28 28 static const int CHUNK_MILLIS = 10; 29 static const int BUFFER_STEP = 1000 0; //ms30 static const int BUFFER_EXTRA = 200 0; //ms29 static const int BUFFER_STEP = 1000; //ms 30 static const int BUFFER_EXTRA = 200; //ms 31 31 static const int BUFFER_LEN = BUFFER_STEP + BUFFER_EXTRA; //ms 32 32 static const int ALLOWED_DIST_MILLIS = 2000; 33 33 … … 36 36 Decoder() { 37 37 isOpen = false; 38 38 } 39 39 40 virtual ~Decoder() { 40 41 if (isOpen) { 41 42 if (videoStream > -1) { … … 44 45 av_free(pFrame); 45 46 avcodec_close(pVideoCodecCtx); 46 47 } 47 if (audioStream > -1) 48 if (audioStream > -1) { 48 49 avcodec_close(pAudioCodecCtx); 50 } 49 51 av_close_input_file(pFormatContext); 50 52 isOpen = false; 51 53 } 52 54 } 55 53 56 int seek(int millis, int flags) { 54 57 assert(isOpen); 55 58 if (av_seek_frame(pFormatContext, -1, millis * 1000, flags) >= 0) { … … 59 62 return -1; 60 63 61 64 } 65 62 66 int seekStream(int millis, int stream, int flags) { 63 67 assert(isOpen); 64 68 int64_t rescaleMillis = rescaleToStream(millis, stream); … … 70 74 return -1; 71 75 72 76 } 77 73 78 int rescaleToStream(int millis, int stream) { 74 79 int num = pFormatContext->streams[stream]->time_base.num; 75 80 int den = pFormatContext->streams[stream]->time_base.den; 76 81 return av_rescale(millis * 1000, den, AV_TIME_BASE * (int64_t) num); 77 82 } 83 78 84 double rescaleToSeconds(int timeStamp, int stream) { 79 85 int num = pFormatContext->streams[stream]->time_base.num; 80 86 int den = pFormatContext->streams[stream]->time_base.den; … … 106 112 while (currentTime <= targetTime && av_read_frame(pFormatContext, 107 113 &packet) >= 0) { 108 114 115 //DUMP(packet.size); 116 109 117 if (first && packet.stream_index == audioStream) { 110 118 double firstSeconds = rescaleToSeconds(packet.pts, 111 119 audioStream); … … 129 137 } 130 138 if (packet.stream_index == audioStream) { 131 139 132 vector<byte> packetSamples = decodeAudio(packet); 133 lastAudioBuffer.insert(lastAudioBuffer.end(), 134 packetSamples.begin(), packetSamples.end()); 135 currentTime = packet.pts + packet.duration; 140 try { 141 vector<byte> packetSamples = decodeAudio(packet); 142 lastAudioBuffer.insert(lastAudioBuffer.end(), 143 packetSamples.begin(), packetSamples.end()); 144 currentTime = packet.pts + packet.duration; 136 145 137 //currentTime += packet.duration; 138 packetSamples.clear(); 146 //currentTime += packet.duration; 147 packetSamples.clear(); 148 } catch(runtime_error const& ex) { 149 cerr << ex.what() << endl; 150 } 139 151 } 140 152 if (packet.data) { 141 153 av_free_packet(&packet); … … 152 164 153 165 return lastAudioBuffer; 154 166 } 167 155 168 vector<byte> getAudio(int millis) { 156 169 assert(isOpen); 157 170 assert(millis >= 0); … … 517 530 }; 518 531 519 532 #endif /* MEDIA_MESSAGES_H_ */ 533 -
sophie2-native/Makefile
3 3 4 4 all : main 5 5 6 libs :7 cd lib-src && $(MAKE)6 #libs : 7 # cd lib-src && $(MAKE) 8 8 9 include ${ROOT}/qt_env9 #include ${ROOT}/qt_env 10 10 11 11 #the only one for now 12 12 main : libs 13 13 cd src/media_decoder && $(MAKE) 14 cd src/audio_output && $(MAKE)15 cd src/browser_embed && qmake && ${MAKE} -f makefile.${PLATF}14 # cd src/audio_output && $(MAKE) 15 # cd src/browser_embed && qmake && ${MAKE} -f makefile.${PLATF} 16 16 17 17 clean-main: 18 18 -rm -r $(MAIN_TARGET_ROOT)