cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bennma...@apache.org
Subject git commit: [CB-3703] added capabilities for wp7
Date Fri, 14 Jun 2013 23:33:29 GMT
Updated Branches:
  refs/heads/master 47d42732f -> 6d3edfc6d


[CB-3703] added capabilities for wp7


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/commit/6d3edfc6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/tree/6d3edfc6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/diff/6d3edfc6

Branch: refs/heads/master
Commit: 6d3edfc6de7ea43bcfcf2049dbd3f9d93fa9504e
Parents: 47d4273
Author: Benn Mapes <benn.mapes@gmail.com>
Authored: Fri Jun 14 16:04:22 2013 -0700
Committer: Benn Mapes <benn.mapes@gmail.com>
Committed: Fri Jun 14 16:17:39 2013 -0700

----------------------------------------------------------------------
 plugin.xml                       |  5 +++++
 src/wp7/UI/AudioRecorder.xaml.cs | 30 +++++++++++++++++++++++++++---
 2 files changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/6d3edfc6/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index f7036e1..5c11f0e 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -71,6 +71,11 @@ id="org.apache.cordova.core.Capture"
             </feature>
         </config-file>
 
+        <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
+            <Capability Name="ID_CAP_MEDIALIB"/>
+            <Capability Name="ID_CAP_MICROPHONE"/>
+        </config-file>
+
         <source-file src="src/wp7/Capture.cs" />
         <source-file src="src/wp7/UI/AudioCaptureTask.cs" />
         <source-file src="src/wp7/UI/AudioRecorder.xaml" />

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture/blob/6d3edfc6/src/wp7/UI/AudioRecorder.xaml.cs
----------------------------------------------------------------------
diff --git a/src/wp7/UI/AudioRecorder.xaml.cs b/src/wp7/UI/AudioRecorder.xaml.cs
index bc8ba6f..6ff0b5c 100644
--- a/src/wp7/UI/AudioRecorder.xaml.cs
+++ b/src/wp7/UI/AudioRecorder.xaml.cs
@@ -122,8 +122,25 @@ namespace WPCordovaClassLib.Cordova.UI
             this.buffer = new byte[microphone.GetSampleSizeInBytes(this.microphone.BufferDuration)];
             this.microphone.BufferReady += new EventHandler<EventArgs>(MicrophoneBufferReady);
 
-            this.memoryStream = new MemoryStream();
-            this.memoryStream.InitializeWavStream(this.microphone.SampleRate);
+            MemoryStream stream = new MemoryStream();
+            this.memoryStream = stream;
+            int numBits = 16;
+            int numBytes = numBits / 8;
+
+            // inline version from AudioFormatsHelper
+            stream.Write(System.Text.Encoding.UTF8.GetBytes("RIFF"), 0, 4);
+            stream.Write(BitConverter.GetBytes(0), 0, 4);
+            stream.Write(System.Text.Encoding.UTF8.GetBytes("WAVE"), 0, 4);
+            stream.Write(System.Text.Encoding.UTF8.GetBytes("fmt "), 0, 4);
+            stream.Write(BitConverter.GetBytes(16), 0, 4);
+            stream.Write(BitConverter.GetBytes((short)1), 0, 2);
+            stream.Write(BitConverter.GetBytes((short)1), 0, 2);
+            stream.Write(BitConverter.GetBytes(this.microphone.SampleRate), 0, 4);
+            stream.Write(BitConverter.GetBytes(this.microphone.SampleRate * numBytes), 0,
4);
+            stream.Write(BitConverter.GetBytes((short)(numBytes)), 0, 2);
+            stream.Write(BitConverter.GetBytes((short)(numBits)), 0, 2);
+            stream.Write(System.Text.Encoding.UTF8.GetBytes("data"), 0, 4);
+            stream.Write(BitConverter.GetBytes(0), 0, 4);
 
             this.duration = new TimeSpan(0);
 
@@ -234,7 +251,13 @@ namespace WPCordovaClassLib.Cordova.UI
                 return new AudioResult(TaskResult.Cancel);
             }
 
-            this.memoryStream.UpdateWavStream();
+            //this.memoryStream.UpdateWavStream();
+            long position = memoryStream.Position;
+            memoryStream.Seek(4, SeekOrigin.Begin);
+            memoryStream.Write(BitConverter.GetBytes((int)memoryStream.Length - 8), 0, 4);
+            memoryStream.Seek(40, SeekOrigin.Begin);
+            memoryStream.Write(BitConverter.GetBytes((int)memoryStream.Length - 44), 0, 4);
+            memoryStream.Seek(position, SeekOrigin.Begin);
 
             // save audio data to local isolated storage
 
@@ -302,5 +325,6 @@ namespace WPCordovaClassLib.Cordova.UI
                 dtXna = null;
             }
         }
+
     }
 }
\ No newline at end of file


Mime
View raw message