Image from iphone app to wcf service - ios

Can any one suggest me that how can I retrive a image from iphone app through WCF web service
and save it to a directory.
I am recieving a image from iphone app in form of NSDATA(Don't know about that,Actually iphone develpoer is giving me a image as Nsdata).
and I am doing like this to convert this data to image and save to my directory
public Image byteArrayToImage(byte[] byteArrayIn)
{
Image returnImage = null;
string ApplicationVerifyPath = ConfigurationManager.AppSettings["ImagePath"].ToString();
ApplicationVerifyPath = ApplicationVerifyPath + "RetailerAdmin/ProductImages/";
using (MemoryStream ms = new MemoryStream(byteArrayIn, 0, byteArrayIn.Length))
{
ms.Write(byteArrayIn, 0, byteArrayIn.Length);
ms.Seek(0, SeekOrigin.Begin);
returnImage = Image.FromStream(ms);
returnImage.Save(ApplicationVerifyPath + returnImage, System.Drawing.Imaging.ImageFormat.Png);
}
return returnImage;
}
it is showing (parameter is invalid error in Image.FromStream(ms).
Kindly help me to get out from this solution.
Image data example
ffd8ffe0 00104a46 49460001 01000001 00010000 ffe10058 45786966 00004d4d 002a0000 00080002
01120003 00000001 00010000 87690004 00000001 00000026 00000000 0003a001 00030000 00010001 0000a002
00040000 00010000 00e1a003 00040000 00010000 00e10000 0000ffdb 00430020 16181c18 14201c1a 1c242220
26305034 302c2c30 62464a3a 5074667a 78726670 6e8090b8 9c8088ae 8a6e70a0 daa2aebe c4ced0ce 7c9ae2f2
e0c8f0b8 cacec6ff db004301 22242430 2a305e34 345ec684 7084c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6
c6c6c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 c6c6c6c6 ffc00011 0800e100 e1030122
00021101 031101ff c4001f00 00010501 01010101 01000000 00000000 00010203 04050607 08090a0b ffc400b5
10000201 03030204 03050504 04000001 7d010203 00041105 12213141 06135161 07227114 328191a1 082342b1
c11552d1 f0243362 7282090a 16171819 1a252627 28292a34 35363738 393a4344 45464748 494a5354 55565758
595a6364 65666768 696a7374 75767778 797a8384 85868788 898a9293 94959697 98999aa2 a3a4a5a6 a7a8a9aa
b2b3b4b5 b6b7b8b9 bac2c3c4 c5c6c7c8 c9cad2d3 d4d5d6d7 d8d9dae1 e2e3e4e5 e6e7e8e9 eaf1f2f3 f4f5f6f7
f8f9faff c4001f01 00030101 01010101 01010100 00000000 00010203 04050607 08090a0b ffc400b5 11000201
02040403 04070504 04000102 77000102 03110405 21310612 41510761 71132232 81081442 91a1b1c1 09233352
f0156272 d10a1624 34e125f1 1718191a 26272829 2a353637 38393a43 44454647 48494a53 54555657 58595a63
64656667 68696a73 74757677 78797a82 83848586 8788898a 92939495 96979899 9aa2a3a4 a5a6a7a8 a9aab2b3
b4b5b6b7 b8b9bac2 c3c4c5c6 c7c8c9ca d2d3d4d5 d6d7d8d9 dae2e3e4 e5e6e7e8 e9eaf2f3 f4f5f6f7 f8f9faff
da000c03 01000211 0311003f 00e828a2 aadede47 6716f7e5 8f0aa3a9 34016738 a85eeedd 0e1e7894 fbb815ce
5c5ddcde 37ef1c85 3d11781f fd7a885b 36385fe9 401d3fdb ad3fe7e6 1ffbec51 f6eb4ff9 f987fefb 15ccfd99
bfba3f31 47d99bfb bfa8a00e 9bedd69f f3f30ffd f628fb75 a7fcfcc3 ff007d8a e67eccdf dd1f98a3 eccdfdd1
f98a00e9 bedd69ff 003f30ff 00df628f b75a7fcf cc3ff7d8 ae67eccd fdd1f98a 3eccdfdd 1f98a00e 9bedd69f
f3f30ffd f628fb75 a7fcfcc3 ff007d8a e67eccdf dd1f98a3 eccde83f 31401d37 dbad3fe7 e61ffbec 51f6eb4f
f9f987fe fb15ccfd 99bd07e6 297eccdf dd1f98a0 0e97edd6 9ff3f30f fdf628fb 75a7fcfc c3ff007d 8ae67ecc
dfdd1f98 a3eccdfd d1f98a00 e9bedd69 ff003f30 ff00df62 8fb75a7f cfcc3ff7 d8ae67ec cde83f31 47d99bfb
a3f31401 d37dbad3 fe7e61ff 00bec51f 6eb4ff00 9f987fef b15ccfd9 9bfba3f3 147d99bf ba3f3140 1d37dbad
3fe7e61f fbec51f6 eb4ff9f9 87fefb15 cd7d99bf ba3f3149 f666fee8 fcc50074 df6eb4ff 009f987f efb147db
ad3fe7e6 1ffbec57 33f666fe e8fcc51f 666feefe a2803a75 bcb56385 b8889f40 e2a60411 906b9236 cd8fbbfa
d2c33dc5 9b7ee5ca e3f84f4f ca803ada 2a8e9da8 25ea107e 5957ef2f f51ed57a 800a28a2 80109c0c d72b7970
6f2eda4c e541c20f 6ae8ef9c a5a4cc3a 8427f4ae 5a100628 0275c20e 3af73464 9ea68a28 00a29296 800e68e6
8a2800a2 8a2800fc 68a28a00 28a4a5a0 028a4a28 0168a292 80168a4a 5a0028a2 8a0028a2 8a0039f5 a52430c3
7e06928a 008e391e d675993a a9e9ea3b 8aeae291 658d5d4e 430c835c 9cb5d068 cc5b4e8b 3d811f91 22802fd1
45140153 51ff008f 19ff00eb 9b7f2ae6 a2ed5d2e a5ff001e 33ff00d7 36fe55cc c5401351 45140051 4945002d
14514005 14514005 14946680 168a4cd2 6e1400ea 29bb87ad 2eea005a 29334500 2d1494b4 00514514 00514514
00514514 011cb5bb a27fc83e 3fc7f99a c296b774 4ff907c7 f53fccd0 06951451 4015352f f8f19ffe b9b7f2ae
662ae9b5 2ff8f19f feb9b7f2 ae662a00 968a4a5a 0028a4a2 80168a4a 28016834 84e2a6b3 b396f1fe 4f9507de
73fd2802 11962154 1627a003 26af5be9 37128065 2221e879 35ad6b67 0daae235 f9bbb1ea 6ac50067 c7a3db27
df2f21f7 381fa54e ba7da01f f1ef19fa 8cd59a69 9635382e a3ea6802 03a7da11 ff001ef1 8fa2e2a1 9348b57f
ba1a33fe cb7f8d5c 13447a48 87fe0429 f401873e 8f320cc2 e241e878 354183c6 db24528c 3b118aea ea2b8b68
ae536ca8 08ec7b8f a5007339 a2ac5f58 4966770f 9e1fef77 1f5aac0e 680168a2 8a0028a2 9280168a 29280192
d6f689ff 0020f8fe a7f99ac1 92b7b44f f907c7f5 3fccd006 95145140 15352ff8 f19ffeb9 b7f2ae62 2ae9f52f
f8f19ffe b9b7f2ae 622a0096 8a4a2801 68a4a280 1690d148 0348eb1a 0cb31c01 40162c6d 1af26db9 c46bf7db
fa574714 69146111 42a81c01 515a5bad adbac4bd ba9f5353 92154963 803a9340 01200c93 802b32e7 57018c76
89e637f7 cfdd1fe3 556eeede fe42884a db838f77 ff00eb51 1a2a2e00 a9723a21 4afab18d f69b8399 a77c7f75
4e0520b3 8fb8c9f5 353e68cd 4dcd9452 20365176 5c52aa4f 01cc13ba fb139153 668cd170 714c96df 57746097
898ffa68 bd3f115a 88eb2207 460ca790 45623287 1c8a8e09 e4d3e4ca 7cd093f3 27f514d4 8c6747aa 3a0650ca
430c83d4 1ae7b52b 236926f8 c7ee58f1 fec9f4ad f8e449a3 5910e558 641a4962 49a368dc 655860d5 9ce72e0e
68a59a26 b6b8785f aa9ebea3 b1a6d002 d1494500 2d149450 0324aded 13fe41f1 fd5bf99a c192b7f4 4ff907c7
f56fe668 034a8a28 a00a9a9f fc78cfff 005cdbf9 572f1575 1a9ffc78 4fff005c dbf9572f 1d004b45 251400b4
52514001 ad0d0e0d f3bcec38 4185fa9a cd63815d 0e931f97 a745c72f f39fc7ff 00ad4017 4726b2f5 9b924ada
21ebcb9f 6ec2b4f2 154b13c0 1cd736ae 669e499b abb67fc2 a64ec8da 8c39a44f 1a851802 9d9a6668 cd6676d8
7e68cd33 346680b0 fcd19a66 68cd0161 f9a6b00c 39a4cd19 a02c4da5 5c1b7b9f b331fddc 9cafb1f4 ad93c1ae
6ae32007 53865390 6ba18651 35bc728f e200d691 671d6872 bb99baec 198d2e14 72a76b7d 0d648391 5d2ddc5e
75a4b1ff 00794e3e bdab9843 95aa301f 45251400 b452519a 006c95bd a1ff00c8 3e3fab7f 33581256 fe87ff00
20f8fead ff00a11a 00d3a28a 28029ea7 ff001e13 ff00d736 fe55cbc7 5d46a7ff 001e13ff 00d736fe 55cbc740
12514514 0052d251 400c9490 a71e95d5 c2a1208d 47f0a815 c94bf70f d2bad560 63523b81 4011deb9 4b19d81e
429ac080 e12b7350 e74f9ffd dae7d0e0 715133b7 0aaf72ce ea37541b 8d2ee350 75f293ee a37541bc d1bcd01c
a4fba8dd 506f346f 34072936 ea37543b 8d26e340 72924ad9 4ad8d218 b69c993f 74902b09 98915b5a 3f1a70ff
0078d544 e5c4ab24 5feb5c99 1b25917f baec3f23 5d58ae52 420dccc4 77918fea 6b43845a 28a2800a 28a28019
25741a17 fc83a3fa b7fe846b 9f92ba0d 0bfe41f1 fd5bff00 423401a7 45145005 3d4ffe3c 27ff00ae 6dfcab96
8eba9d4f fe3c27ff 00ae6dfc ab968e80 24a2928a 005a2928 a006b8c8 ae974f93 cdd3e06f f6003f51 c5736dd2
b5f40981 864809e5 0ee1f434 01a52287 8dd0ff00 12915cc2 e54953d4 1c1aea1b 8ac2d520 30dd79aa 3e4939fc
7bd4491d 1879f2ca c56a2933 45667a37 168a4a28 0b8b4525 1405c5a2 928cd017 11ce16ba 2b28cc56 71211ced
c9fc6b0e ca037374 aa47c8bc b7d2ba21 c9ad22ba 9c1899dd d824711c 4ee7a2a9 26b938f2 464f53c9 adfd6a6f
2ac0a03f 34a768fa 77ac15e0 559ca3e8 a4a28017 34525140 0d7ae874 2ff907c7 f56ffd08 d73cf5d0 e85ff20e
8feadffa 11a00d3a 28a28029 ea7ff1e1 3ffd736f e55cac75 d56a7ff1 e13ffd73 6fe55caa 5003e969 28a00296
928a000d 3ed2e0da 5da4dd87 0c3da994 d619a00e b32aea19 4e548c82 2abdcc2b 3c4d1bf4 3d0fa1ac ed1aff00
6e2d263c 7fcb363f cab61968 04ec7332 c6f04a63 90608fd6 9335bb73 6d1dc26d 9074e8c3 a8ac6b8b 49ad8e48
de9fde1f d6b3713b 69d74f46 47453036 69d9a93a 3993168a 4cd216c5 01cc8752 00d23844 1b98f402 9f05bcd7
27f76bf2 f763d056 c5a59c76 c3e5f99c f56354a3 730a9592 d10fb2b6 16d0ec07 2c7963ef 57145314 567eb17e
21436d11 fde30f98 8fe11fe3 5a1c4ddd dd99fa9d d0bbbd25 4e638fe5 5f7f5355 c714c418 14fa042d 25145002
d1494500 35eba2d0 bfe41d1f d5bff423 5cebd743 a17fc83a 3fab7fe8 46803528 a28a00a7 a9ff00c7 84ff00f5
cdbf9572 895d5ea7 ff001e13 ff00d736 fe55ca25 003e8a28 a0028a28 a0028345 1400c65a d7d3b560 4082e8e0
f4590f7f ad651a6b 2e6803ac 65c8e2a3 208ae7ed 3519ecc6 d07cc8ff 00b8ddbe 9e95af6f aa5acfc1 6f29ff00
baff00e3 4004b656 d29cb440 1f55e2a0 3a4c24f1 2c8bed8c d69050c3 2a4107b8 a361a564 52935b33 306910e7
99a43f80 a9e3b0b5 8cf116e3 eae73573 61a5da00 e68b2073 6fa8c038 e071e952 2a5559f5 1b4b6183 26f6feea
726b26ef 559ee414 8c7951fa 03c9fa9a 649a1a8e aab0030d b90f2f76 ecbffd7a c3e598b3 12c49c92 7a9a4550
074a78e2 80147145 14500145 14500145 1450035e ba2d0bfe 41d1fd5b ff004235 cebd745a 17fc83a3 fab7fe84
6803528a 28a00a7a a7fc784f ff005cdb f957269d abacd53f e3c2e3fe b9b7f2ae 4d2801f4 51450014 5252d001
45145001 45149400 100d34a8 3da9f494 00d46923 3fbb774f f75b153a dfdea0e2 e1ff001c 1a8a8c0a 0095b50b
d61cdc37 e000a85d e597fd6c aeff00ef 3134b8a3 02801a10 0e829c00 1452d001 45145001 45149400 b4514500
14514500 35aba3d0 bfe41d1f d5bff423 5ce35747 a0ff00c8 3a2fab7f e8468035 28a28a00 a7aa7fc7 84ff00f5
cdbf9572 69dabadd 48136338 1ff3cdbf 957229d2 801f4525 1400b452 52d00145 251400b4 5251400b 45251400
b4514500 14514940 0b452514 00b45251 400b4525 1400b452 51400b45 2514008d 5d2683ff 0020e8be adff00a1
1ae6daba 5d0b8d3a 2fc7f99a 00d3a28a 280229d7 72104704 571d2c4d 04ef1375 53f98ed5 da30c8ac 6d574ff3
ff007883 120fd680 30fad14d 21918ab8 2ac3a834 b9a005a2 93346680 168a4cd1 9a005a29 33466801 68a4cd19
a005a293 34668016 8a4cd19a 005a2933 46680168 a4cd19a0 05a29334 6680168a 4cd19a00 5a293349 924e00c9
3d00a005 c33b0551 9663802b aeb18843 6f1c63f8 540ac8d2 b4e64613 4c3e7fe1 1e9ffd7a de45c2d0 03e8a28a
002a3910 30a928a0 0cdb9b18 e618740d fcea8b68 d0e78320 f606b7c8 069be58f 4a00c0fe c68bfbd2 7e63fc28
fec68bfb d27e63fc 2b7fcb1e 947963d2 80303fb1 a2fef49f 98ff000a 3fb1a2fe f49f98ff 000adff2 c7a51e58
f4a00c0f ec68bfbd 27e63fc2 8fec68bf bd27e63f c2b7fcb1 e947963d 280303fb 1a2fef49 f98ff0a3 fb1a2fef
49f98ff0 adff002c 7a51e58f 4a00c0fe c68bfbd2 7e63fc28 fec68bfb d27e63fc 2b7fcb1e 947963d2 80303fb1
a2fef49f 98ff000a 3fb1a2fe f49f98ff 000adff2 c7a51e58 f4a00c0f ec68bfbd 27e63fc2 8fec68bf bd27e63f
c2b7fcb1 e947963d 280303fb 1a2fef49 f98ff0a3 fb1a2fef 49f98ff0 adff002c 7a51e58f 4a00c0fe c68bfbd2
7e63fc28 fec68bfb d27e63fc 2b7fcb1e 947963d2 80303fb1 a2fef49f 98ff000a 3fb1a2fe f49f98ff 000adff2
c7a51e58 f4a00c11 a3459e5a 43f8d5cb 6d3e2879 4400faf7 ad2f2c52 85028019 1c61474a 92968a00 28a28a00
28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 28a28a00 28a28a00
28a28a00 28a28a00 28a28a00 28a28a00 ffd9

You can try the below way as I had implemented in one of my project when intergrating WCF REST service in iPhone.
Get NSDATA to string property or variable. Use this string as Base64 string and convert it into an image and save it to your directory.
public void Base64ToImage(string imageString)
{
// Convert Base64 String to byte[]
byte[] imageBytes = Convert.FromBase64String(imageString);
MemoryStream ms = new MemoryStream(imageBytes, 0,
imageBytes.Length);
// Convert byte[] to Image
ms.Write(imageBytes, 0, imageBytes.Length);
System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
image.Save("Base64ToImage.png"); //Specify your filename here
}

Related

Connection of varispeed with RemoteIO in iOS

I am working with audio units to play and change the speed of playback. Since AudioGraph is deprecated.
What I have done, I have successfully played Audio coming from UDP via audio-units and made connections like:
converterUnit -> varispeed -> outConverterUnit -> RemoteIO (Out)
Our format for playing is int16(PCM), but varispeed requires float datatype, So we are using converters for varispeed.
Here is my code:
var ioFormat = CAStreamBasicDescription(
sampleRate: 48000.0,
numChannels: 1,
pcmf: .int16,
isInterleaved: false
)
var varispeedFormat = CAStreamBasicDescription(
sampleRate: 16000,
numChannels: 1,
pcmf: .float32,
isInterleaved: false
)
init(_ client: UDPClient, _ tcpClient: TCPClient, _ opusHelper: OpusHelper, _ tvTemp: UILabel) {
super.init()
let success = initCircularBuffer(&circularBuffer, 4096)
if success {
print("Circular buffer init was successful")
} else {
print("Circular buffer init not successful")
}
self.opusHelper = opusHelper
self.tvTemp = tvTemp
monotonicTimer = MonotonicTimer()
self.udpClient = client
self.tcpClient = tcpClient
//Creating Description for REMOTE IO
var outputDesc = AudioComponentDescription(
componentType: OSType(kAudioUnitType_Output),
componentSubType: OSType(kAudioUnitSubType_VoiceProcessingIO),
componentManufacturer: OSType(kAudioUnitManufacturer_Apple),
componentFlags: 0,
componentFlagsMask: 0
)
let inputComponent = AudioComponentFindNext(nil, &outputDesc)
check(error: AudioComponentInstanceNew(inputComponent!, &outputUnit), description: "Output unit instance new failed")
//Creating Description for converterUnit
var firstConverterDesc = AudioComponentDescription(
componentType: OSType(kAudioUnitType_FormatConverter),
componentSubType: OSType(kAudioUnitSubType_AUConverter),
componentManufacturer: OSType(kAudioUnitManufacturer_Apple),
componentFlags: 0,
componentFlagsMask: 0
)
let firstConverterComponent = AudioComponentFindNext(nil, &firstConverterDesc)
check(error: AudioComponentInstanceNew(firstConverterComponent!, &firstConverterUnit), description: "First converter unit instance new failed")
//Creating Description for Varispeed Unit
var variSpeedConverterDesc = AudioComponentDescription(
componentType: OSType(kAudioUnitType_FormatConverter),
componentSubType: OSType(kAudioUnitSubType_Varispeed),
componentManufacturer: OSType(kAudioUnitManufacturer_Apple),
componentFlags: 0,
componentFlagsMask: 0
)
let variSpeedConverterComponent = AudioComponentFindNext(nil, &variSpeedConverterDesc)
check(error: AudioComponentInstanceNew(variSpeedConverterComponent!, &varispeedUnit), description: "First converter unit instance new failed")
//Creating Description for outConverter
var secondConverterDesc = AudioComponentDescription(
componentType: OSType(kAudioUnitType_FormatConverter),
componentSubType: OSType(kAudioUnitSubType_AUConverter),
componentManufacturer: OSType(kAudioUnitManufacturer_Apple),
componentFlags: 0,
componentFlagsMask: 0
)
let secondConverterComponent = AudioComponentFindNext(nil, &secondConverterDesc)
check(error: AudioComponentInstanceNew(secondConverterComponent!, &secondConverterUnit), description: "Second converter unit instance new failed")
//Converting incoming bytes to AUConverter (Float 32 format)
check(error: AudioUnitSetProperty(
firstConverterUnit!,
AudioUnitPropertyID(kAudioUnitProperty_StreamFormat),
AudioUnitScope(kAudioUnitScope_Output),
0,
&varispeedFormat,
MemoryLayoutStride.SizeOf32(varispeedFormat)
),
description: "Failed to set input of second converter to our temp format"
)
//Putting converted bytes in varispeed unit
check(error: AudioUnitSetProperty(
varispeedUnit!,
AudioUnitPropertyID(kAudioUnitProperty_StreamFormat),
AudioUnitScope(kAudioUnitScope_Input),
0,
&varispeedFormat,
MemoryLayoutStride.SizeOf32(varispeedFormat)
),
description: "Failed to set input format as varispeed format of the second converter unit"
)
//Getting converted bytes from varispeed unit
check(error: AudioUnitSetProperty(
varispeedUnit!,
AudioUnitPropertyID(kAudioUnitProperty_StreamFormat),
AudioUnitScope(kAudioUnitScope_Output),
0,
&varispeedFormat,
MemoryLayoutStride.SizeOf32(varispeedFormat)
),
description: "Failed to set input format as varispeed format of the second converter unit"
)
//Putting converted bytes in outConverterUnit
check(error: AudioUnitSetProperty(
secondConverterUnit!,
AudioUnitPropertyID(kAudioUnitProperty_StreamFormat),
AudioUnitScope(kAudioUnitScope_Input),
0,
&varispeedFormat,
MemoryLayoutStride.SizeOf32(varispeedFormat)
),
description: "Failed to set input of second converter to our temp11 format"
)
//Getting converted bytes from outConverterUnit in int16(PCM)
check(error: AudioUnitSetProperty(
secondConverterUnit!,
AudioUnitPropertyID(kAudioUnitProperty_StreamFormat),
AudioUnitScope(kAudioUnitScope_Output),
0,
&ioFormat,
MemoryLayoutStride.SizeOf32(ioFormat)
),
description: "Failed to set input of second converter to our temp11 format"
)
//Connecting firstConverter to varispeed
var tempConnection = AudioUnitConnection(
sourceAudioUnit: firstConverterUnit!,
sourceOutputNumber: 0,
destInputNumber: 0
)
check(error: AudioUnitSetProperty(
varispeedUnit!,
AudioUnitPropertyID(kAudioUnitProperty_MakeConnection),
AudioUnitScope(kAudioUnitScope_Input),
0,
&tempConnection,
MemoryLayoutStride.SizeOf32(AudioUnitConnection())
),
description: "Failed to connect second converter to output Unit"
)
//Connecting verispeedUnit to to outConverter
var temp1Connection = AudioUnitConnection(
sourceAudioUnit: varispeedUnit!,
sourceOutputNumber: 0,
destInputNumber: 0
)
check(error: AudioUnitSetProperty(
secondConverterUnit!,
AudioUnitPropertyID(kAudioUnitProperty_MakeConnection),
AudioUnitScope(kAudioUnitScope_Input),
0,
&temp1Connection,
MemoryLayoutStride.SizeOf32(AudioUnitConnection())
),
description: "Failed to connect second converter to output Unit"
)
//Connecting outConverter to outputUnit
var secondToOutputConnection = AudioUnitConnection(
sourceAudioUnit: secondConverterUnit!,
sourceOutputNumber: 0,
destInputNumber: 0
)
check(error: AudioUnitSetProperty(
outputUnit!,
AudioUnitPropertyID(kAudioUnitProperty_MakeConnection),
AudioUnitScope(kAudioUnitScope_Input),
0,
&secondToOutputConnection,
MemoryLayoutStride.SizeOf32(AudioUnitConnection())
),
description: "Failed to connect second converter to output Unit"
)
check(error: AudioUnitInitialize(outputUnit!), description: "Failed to init output unit")
check(error: AudioUnitInitialize(firstConverterUnit!), description: "Failed to init first converter unit")
check(error: AudioUnitInitialize(varispeedUnit!), description: "Failed to init varispeed unit")
check(error: AudioUnitInitialize(secondConverterUnit!), description: "Failed to init second converter unit")
var playbackCallback = AURenderCallbackStruct(
inputProc: AudioController_PlaybackCallback,
inputProcRefCon: UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque())
)
check(error: AudioUnitSetProperty(
outputUnit!,
AudioUnitPropertyID(kAudioUnitProperty_SetRenderCallback),
AudioUnitScope(kAudioUnitScope_Input),
kOutputBus,
&playbackCallback,
MemoryLayout<AURenderCallbackStruct>.size.ui
),
description: "Failed to set recording render callback"
)
}
The parameter for changing the playback speed is given here.
func performPlayback(
_ ioActionFlags: UnsafeMutablePointer<AudioUnitRenderActionFlags>,
inTimeStamp: UnsafePointer<AudioTimeStamp>,
inBufNumber: UInt32,
inNumberFrames: UInt32,
ioData: UnsafeMutablePointer<AudioBufferList>
) -> OSStatus {
let buffer = ioData[0].mBuffers
let bytesToCopy = ioData[0].mBuffers.mDataByteSize
var bufferTail: UnsafeMutableRawPointer?
// print("BYTES TO COPY: \(bytesToCopy)")
self.availableBytes = 0
bufferTail = TPCircularBufferTail(&self.circularBuffer, &self.availableBytes)
bytesToWrite = min(bytesToCopy, self.availableBytes)
check(error: AudioUnitSetParameter(
varispeedUnit!,
AudioUnitParameterID(kVarispeedParam_PlaybackRate),
AudioUnitScope(kAudioUnitScope_Global),
0,
AudioUnitParameterValue(1.9999000082426955),
0
),
description: "Failed to set parameter rate for varispeed unit"
)
print("BYTES TO WRITE: \(bytesToWrite)")
if bytesToWrite >= 3840 {
memcpy(buffer.mData, bufferTail, Int(bytesToWrite))
TPCircularBufferConsume(&self.circularBuffer, bytesToWrite)
} else {
let silence = [Int16](repeating: 0, count: Int(bytesToCopy))
memcpy(buffer.mData, silence, Int(bytesToCopy))
}
return noErr
}
The problem is, I don't feel any difference in voice if I use varispeed or not. Can anyone point out the problem in my code?
https://stackoverflow.com/a/60552075/7798783
https://stackoverflow.com/a/34750857/7798783
https://stackoverflow.com/a/34671010/7798783
I have studied these answers and tried to implement them in our situation with no result.
I think scopes and elements might be the problem.

Face Recognition in Videos with OpenCV3 gives Unhandled exception (opencv_core310.dll)

Below code used to recognize face which i got from the below link
http://docs.opencv.org/3.0-beta/modules/face/doc/facerec/tutorial/facerec_video_recognition.html.
The only modification I've done is: Instead of using command line arguments to provide CSV and Cascade classifier paths, I have given them directly in the code.
Problem
Exception thrown at 0x00007FFDD0C0E09B (opencv_core310.dll) in facerecognization.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
i am getting access violation problem as shown .
To solve problem i tried to
1)to debug step by step i get the exception when code reaches this line
CascadeClassifier haar_cascade; after model->train
2)i reinstalled twice everything ie opencv_contru but again i same problem
3) i initially used at&t database as at.txt and since it use .pgm file (windows doesnt recognize and when i ran same problem),so i created my own data base with .jpg ie facecsv.txt(my database with 10 sets) but same problem persist
4) i changed haarcascade_frontalface_default.xml to other .xml files but still the same problem
5)dll is not a problem as configured it twice
code
#include "opencv2/core.hpp"
#include "opencv2/face.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/objdetect.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
using namespace cv;
using namespace cv::face;
using namespace std;
int abc;
static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
std::ifstream file(filename.c_str(), ifstream::in);
if (!file) {
string error_message = "No valid input file was given, please check the given filename.";
CV_Error(CV_StsBadArg, error_message);
}
string line, path, classlabel;
while (getline(file, line)) {
stringstream liness(line);
getline(liness, path, separator);
getline(liness, classlabel);
if (!path.empty() && !classlabel.empty()) {
images.push_back(imread(path, 0));
labels.push_back(atoi(classlabel.c_str()));
}
}
}
int main(int argc, const char *argv[]) {
// Get the path to your CSV:
string fn_haar = "C:\\OpenCV-3.1.0\\opencv\\build2\\install\\etc\\haarcascades\\haarcascade_frontalface_default.xml";
string fn_csv = "C:\\OpenCV-3.1.0\\facedata\\facecsv.txt";
int deviceId = 0;
// These vectors hold the images and corresponding labels:
vector<Mat> images;
vector<int> labels;
// Read in the data (fails if no valid input filename is given, but you'll get an error message):
try {
read_csv(fn_csv, images, labels);
}
catch (cv::Exception& e) {
cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
// nothing more we can do
cin >> abc;
exit(1);
}
// Get the height from the first image. We'll need this
// later in code to reshape the images to their original
// size AND we need to reshape incoming faces to this size:
int im_width = images[0].cols;
int im_height = images[0].rows;
// Create a FaceRecognizer and train it on the given images:
Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
model->train(images, labels);
// That's it for learning the Face Recognition model. You now
// need to create the classifier for the task of Face Detection.
// We are going to use the haar cascade you have specified in the
// command line arguments:
//
CascadeClassifier haar_cascade;
haar_cascade.load(fn_haar);
// Get a handle to the Video device:
VideoCapture cap(deviceId);
// Check if we can use this device at all:
if (!cap.isOpened()) {
cerr << "Capture Device ID " << deviceId << "cannot be opened." << endl;
return -1;
}
// Holds the current frame from the Video device:
Mat frame;
for (;;) {
cap >> frame;
// Clone the current frame:
Mat original = frame.clone();
// Convert the current frame to grayscale:
Mat gray;
cvtColor(original, gray, CV_BGR2GRAY);
// Find the faces in the frame:
vector< Rect_<int> > faces;
haar_cascade.detectMultiScale(gray, faces);
// At this point you have the position of the faces in
// faces. Now we'll get the faces, make a prediction and
// annotate it in the video. Cool or what?
for (int i = 0; i < faces.size(); i++) {
// Process face by face:
Rect face_i = faces[i];
// Crop the face from the image. So simple with OpenCV C++:
Mat face = gray(face_i);
// Resizing the face is necessary for Eigenfaces and Fisherfaces. You can easily
// verify this, by reading through the face recognition tutorial coming with OpenCV.
// Resizing IS NOT NEEDED for Local Binary Patterns Histograms, so preparing the
// input data really depends on the algorithm used.
//
// I strongly encourage you to play around with the algorithms. See which work best
// in your scenario, LBPH should always be a contender for robust face recognition.
//
// Since I am showing the Fisherfaces algorithm here, I also show how to resize the
// face you have just found:
Mat face_resized;
cv::resize(face, face_resized, Size(im_width, im_height), 1.0, 1.0, INTER_CUBIC);
// Now perform the prediction, see how easy that is:
int prediction = model->predict(face_resized);
// And finally write all we've found out to the original image!
// First of all draw a green rectangle around the detected face:
rectangle(original, face_i, CV_RGB(0, 255, 0), 1);
// Create the text we will annotate the box with:
string box_text = format("Prediction = %d", prediction);
// Calculate the position for annotated text (make sure we don't
// put illegal values in there):
int pos_x = std::max(face_i.tl().x - 10, 0);
int pos_y = std::max(face_i.tl().y - 10, 0);
// And now put it into the image:
putText(original, box_text, Point(pos_x, pos_y), FONT_HERSHEY_PLAIN, 1.0, CV_RGB(0, 255, 0), 2.0);
}
// Show the result:
imshow("face_recognizer", original);
// And display it:
char key = (char)waitKey(20);
// Exit this loop on escape:
if (key == 27)
break;
}
return 0;
}
my database looks like
facecsv.txt
C:\OpenCV-3.1.0\facedata\Angelina Jolie/Angelina_1.jpg;0
C:\OpenCV-3.1.0\facedata\Angelina Jolie/Angelina_2.jpg;0
C:\OpenCV-3.1.0\facedata\Angelina Jolie/angelina_3.jpg;0
C:\OpenCV-3.1.0\facedata\Arnold Schwarzenegger/Arnold_1.jpg;1
C:\OpenCV-3.1.0\facedata\Arnold Schwarzenegger/Arnold_2.jpg;1
C:\OpenCV-3.1.0\facedata\Arnold Schwarzenegger/Arnold_3.jpg;1
C:\OpenCV-3.1.0\facedata\Brad Pitt/Brad_1.jpg;2
C:\OpenCV-3.1.0\facedata\Brad Pitt/Brad_2.jpg;2
C:\OpenCV-3.1.0\facedata\Brad Pitt/Brad_3.jpg;2
C:\OpenCV-3.1.0\facedata\Emma Watson/Emma_1.jpg;3
C:\OpenCV-3.1.0\facedata\Emma Watson/Emma_2.jpg;3
C:\OpenCV-3.1.0\facedata\Emma Watson/Emma_3.jpg;3
C:\OpenCV-3.1.0\facedata\Justin Timberlake/Justin_1.jpg;4
C:\OpenCV-3.1.0\facedata\Justin Timberlake/Justin_2.jpg;4
C:\OpenCV-3.1.0\facedata\Justin Timberlake/Justin_3.jpg;4
C:\OpenCV-3.1.0\facedata\Katy Perry/Katy_1.jpg;5
C:\OpenCV-3.1.0\facedata\Katy Perry/Katy_2.jpg;5
C:\OpenCV-3.1.0\facedata\Katy Perry/Katy_3.jpg;5
C:\OpenCV-3.1.0\facedata\Keanu Reeves/Keanu_1.jpg;6
C:\OpenCV-3.1.0\facedata\Keanu Reeves/Keanu_2.jpg;6
C:\OpenCV-3.1.0\facedata\Keanu Reeves/Keanu_3.jpg;6
C:\OpenCV-3.1.0\facedata\Nisarg/Nisarg_1.jpg;7
C:\OpenCV-3.1.0\facedata\Nisarg/Nisarg_2.jpg;7
C:\OpenCV-3.1.0\facedata\Nisarg/Nisarg_3.jpg;7
C:\OpenCV-3.1.0\facedata\Nisarg/Nisarg_4.jpg;7
C:\OpenCV-3.1.0\facedata\Nisarg/Nisarg_5.jpg;7
C:\OpenCV-3.1.0\facedata\Tom Cruise/Tom_1.jpg;8
C:\OpenCV-3.1.0\facedata\Tom Cruise/Tom_2.jpg;8
C:\OpenCV-3.1.0\facedata\Tom Cruise/Tom_3.jpg;8
and at&t database
C:\OpenCV-3.1.0\att_faces (1)\database\s1/1.pgm;0
C:\OpenCV-3.1.0\att_faces (1)\database\s1/10.pgm;0
C:\OpenCV-3.1.0\att_faces (1)\database\s1/2.pgm;0
C:\OpenCV-3.1.0\att_faces (1)\database\s1/3.pgm;0
C:\OpenCV-3.1.0\att_faces (1)\database\s1/4.pgm;0
C:\OpenCV-3.1.0\att_faces (1)\database\s1/5.pgm;0
C:\OpenCV-3.1.0\att_faces (1)\database\s1/6.pgm;0
C:\OpenCV-3.1.0\att_faces (1)\database\s1/7.pgm;0
C:\OpenCV-3.1.0\att_faces (1)\database\s1/8.pgm;0
C:\OpenCV-3.1.0\att_faces (1)\database\s1/9.pgm;0
C:\OpenCV-3.1.0\att_faces (1)\database\s10/1.pgm;1
C:\OpenCV-3.1.0\att_faces (1)\database\s10/10.pgm;1
C:\OpenCV-3.1.0\att_faces (1)\database\s10/2.pgm;1
C:\OpenCV-3.1.0\att_faces (1)\database\s10/3.pgm;1
C:\OpenCV-3.1.0\att_faces (1)\database\s10/4.pgm;1
C:\OpenCV-3.1.0\att_faces (1)\database\s10/5.pgm;1
C:\OpenCV-3.1.0\att_faces (1)\database\s10/6.pgm;1
C:\OpenCV-3.1.0\att_faces (1)\database\s10/7.pgm;1
C:\OpenCV-3.1.0\att_faces (1)\database\s10/8.pgm;1
C:\OpenCV-3.1.0\att_faces (1)\database\s10/9.pgm;1
C:\OpenCV-3.1.0\att_faces (1)\database\s11/1.pgm;2
C:\OpenCV-3.1.0\att_faces (1)\database\s11/10.pgm;2
C:\OpenCV-3.1.0\att_faces (1)\database\s11/2.pgm;2
C:\OpenCV-3.1.0\att_faces (1)\database\s11/3.pgm;2
C:\OpenCV-3.1.0\att_faces (1)\database\s11/4.pgm;2
C:\OpenCV-3.1.0\att_faces (1)\database\s11/5.pgm;2
C:\OpenCV-3.1.0\att_faces (1)\database\s11/6.pgm;2
C:\OpenCV-3.1.0\att_faces (1)\database\s11/7.pgm;2
C:\OpenCV-3.1.0\att_faces (1)\database\s11/8.pgm;2
C:\OpenCV-3.1.0\att_faces (1)\database\s11/9.pgm;2
C:\OpenCV-3.1.0\att_faces (1)\database\s12/1.pgm;3
C:\OpenCV-3.1.0\att_faces (1)\database\s12/10.pgm;3
C:\OpenCV-3.1.0\att_faces (1)\database\s12/2.pgm;3
C:\OpenCV-3.1.0\att_faces (1)\database\s12/3.pgm;3
C:\OpenCV-3.1.0\att_faces (1)\database\s12/4.pgm;3
C:\OpenCV-3.1.0\att_faces (1)\database\s12/5.pgm;3
C:\OpenCV-3.1.0\att_faces (1)\database\s12/6.pgm;3
C:\OpenCV-3.1.0\att_faces (1)\database\s12/7.pgm;3
C:\OpenCV-3.1.0\att_faces (1)\database\s12/8.pgm;3
C:\OpenCV-3.1.0\att_faces (1)\database\s12/9.pgm;3
C:\OpenCV-3.1.0\att_faces (1)\database\s13/1.pgm;4
C:\OpenCV-3.1.0\att_faces (1)\database\s13/10.pgm;4
C:\OpenCV-3.1.0\att_faces (1)\database\s13/2.pgm;4
C:\OpenCV-3.1.0\att_faces (1)\database\s13/3.pgm;4
C:\OpenCV-3.1.0\att_faces (1)\database\s13/4.pgm;4
C:\OpenCV-3.1.0\att_faces (1)\database\s13/5.pgm;4
C:\OpenCV-3.1.0\att_faces (1)\database\s13/6.pgm;4
C:\OpenCV-3.1.0\att_faces (1)\database\s13/7.pgm;4
C:\OpenCV-3.1.0\att_faces (1)\database\s13/8.pgm;4
C:\OpenCV-3.1.0\att_faces (1)\database\s13/9.pgm;4
and it goes upto 40 test sample s1 to s40
Problem
Exception thrown at 0x00007FFDD0C0E09B (opencv_core310.dll) in facerecognization.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
I am using Windows 10 64-bit with Visual Studio 2015 and OpenCV 3.1.0 and opencv_contrib-master (Build Configuration: x64-Debug)
Their is similar question here Face Recognition in Video using OpenCV gives unhandled exception
but he used only one 1 label but i use more than 8 that didn't solved my problem
I am using Windows 10 64-bit with Visual Studio 2015 and OpenCV 3.1.0 and opencv_contrib-master (Build Configuration: x64-Debug)
You're linking to release libraries, but you're in debug mode.
In debug you need to link to OpenCV libraries with the trailing "d": opencv_<module><version>d.lib.
So in your case to: opencv_core310d.lib, etc...

NSUserDefaults only loads correctly half of the time

I am currently creating an app with Swift2 that stores user entered data. Right now I am just using NSUserDefaults even though I will be using an external DB in the future.
With my current implementation, I have 2 Dictionaries stored to NSUserDefaults. "allNouns", "myNouns", and "nounTimes". When I load my app, the data only loads every other time. I have my code to get the data and the log print outs below.
func saveObject(object: AnyObject, objectKey: String) {
let objectData = NSKeyedArchiver.archivedDataWithRootObject(object)
NSUserDefaults.standardUserDefaults().setObject(objectData, forKey: objectKey)
}
func loadObject(objectKey: String) -> AnyObject? {
var object : AnyObject? = nil
if( NSUserDefaults.standardUserDefaults().objectForKey(objectKey) != nil ) {
let objectData = NSUserDefaults.standardUserDefaults().objectForKey(objectKey) as? NSData
if let objectData = objectData {
object = NSKeyedUnarchiver.unarchiveObjectWithData(objectData)!
}
}
return object
}
override func viewDidLoad() {
super.viewDidLoad()
if( NSUserDefaults.standardUserDefaults().objectForKey("allNouns") != nil ) {
allNouns = loadObject("allNouns") as! [Int : Noun]
allNounIdList = Array(allNouns.keys)
}
if( NSUserDefaults.standardUserDefaults().objectForKey("myNouns") != nil ) {
myNouns = loadObject("myNouns") as! [Int : [NSDate]]
myNounIdList = Array(myNouns.keys)
}
}
Here are all the places I save data:
func stashNoun(nounId: Int) {
let myNounTimes = myNouns[nounId]
if( myNounTimes == nil || myNounTimes!.isEmpty ) {
myNouns[nounId] = [ NSDate() ]
myNounIdList.append(nounId)
}
else {
myNouns[nounId]!.append(NSDate())
}
saveObject(myNouns, objectKey: "my")
}
#IBAction func addButtonClicked(sender: AnyObject) {
let newNoun = Noun(name: nameTextField, type: typeTextField, year: yearTextField)
allNouns[newNoun.id] = newNoun
allNounIdList.append(newNoun.id)
saveObject(allNouns, objectKey: "allNouns")
}
Here is a log of when I have data:
["AppleKeyboards": (
"en_US#hw=US;sw=QWERTY",
"emoji#sw=Emoji",
"en_US#hw=US;sw=QWERTY"
), "allNouns": <62706c69 73743030 d4010203 04050665 66582476 65727369 6f6e5824 6f626a65 63747359 24617263 68697665 72542474 6f701200 0186a0af 10130708 1718191a 1b292a31 3f404e4f 50515260 6155246e 756c6cd3 090a0b0c 1116574e 532e6b65 79735a4e 532e6f62 6a656374 73562463 6c617373 a40d0e0f 10800280 03800480 05a41213 14158006 8009800b 80108012 13688188 08c2d54a e71391c9 681dc633 746913ce dfdb57f5 78a12113 cddfb115 bd62466c d71c1d0b 1e1f2021 22222425 26222256 72656769 6f6e5563 6f6c6f72 52696454 79656172 54747970 65546e61 6d658007 80078008 13688188 08c2d54a e7100380 07800751 63d22b2c 2d2e5a24 636c6173 736e616d 65582463 6c617373 65735e43 6f726b53 74617368 2e57696e 65a22f30 5e436f72 6b537461 73682e57 696e6558 4e534f62 6a656374 d732330b 34353637 3838243b 3c383856 72656769 6f6e5563 6f6c6f72 52696454 79656172 54747970 65546e61 6d65800a 800a8008 1391c968 1dc63374 69100280 0a800a51 62d74142 0b434445 46474824 4a4b4c4d 56726567 696f6e55 636f6c6f 72526964 54796561 72547479 7065546e 616d6580 0e800f80 0813cedf db57f578 a1211107 c5800d80 0c5f101a 696c6927 73207375 70657220 64656c69 63696f75 73207769 6e655c70 696e6f74 20677269 67696f5a 41757374 72616c69 616e5577 68697465 d753540b 55565758 5959245c 5d595956 72656769 6f6e5563 6f6c6f72 52696454 79656172 54747970 65546e61 6d658011 80118008 13cddfb1 15bd6246 6c100180 11801151 61d22b2c 62635c4e 53446963 74696f6e 617279a2 64305c4e 53446963 74696f6e 6172795f 100f4e53 4b657965 64417263 68697665 72d16768 54726f6f 74800100 08001100 1a002300 2d003200 37004d00 53005a00 62006d00 74007900 7b007d00 7f008100 86008800 8a008c00 8e009000 9900a200 ab00b400 c300ca00 d000d300 d800dd00 e200e400 e600e800 f100f300 f500f700 f900fe01 09011201 21012401 33013c01 4b015201 58015b01 60016501 6a016c01 6e017001 79017b01 7d017f01 81019001 97019d01 a001a501 aa01af01 b101b301 b501be01 c101c301 c501e201 ef01fa02 00020f02 16021c02 1f022402 29022e02 30023202 34023d02 3f024102 43024502 4a025702 5a026702 79027c02 81000000 00000002 01000000 00000000 69000000 00000000 00000000 00000002 83>, "AppleKeyboardsExpanded": 1, "AddingEmojiKeybordHandled": 1, "AppleLanguages": (
"en-US"
), "ApplePasscodeKeyboards": (
"en_US"
), "nounTimes": <62706c69 73743030 d4010203 0405063f 40582476 65727369 6f6e5824 6f626a65 63747359 24617263 68697665 72542474 6f701200 0186a0af 100f0708 15161718 1d21272a 2d313438 3b55246e 756c6cd3 090a0b0c 1014574e 532e6b65 79735a4e 532e6f62 6a656374 73562463 6c617373 a30d0e0f 80028003 8004a311 12138005 800a800c 800e1368 818808c2 d54ae713 cddfb115 bd62466c 13cedfdb 57f578a1 21d20a0b 191ca21a 1b800680 088009d2 1e0b1f20 574e532e 74696d65 2341bbaa 1eb23666 778007d2 22232425 5a24636c 6173736e 616d6558 24636c61 73736573 564e5344 617465a2 2426584e 534f626a 656374d2 1e0b2820 2341bbab 0aa3ea33 6a8007d2 22232b2c 574e5341 72726179 a22b26d2 0a0b2e1c a12f800b 8009d21e 0b322023 41bbaa1c 3b5fcfc4 8007d20a 0b351ca1 36800d80 09d21e0b 39202341 bbab0a88 d0ea0780 07d22223 3c3d5c4e 53446963 74696f6e 617279a2 3e265c4e 53446963 74696f6e 6172795f 100f4e53 4b657965 64417263 68697665 72d14142 54726f6f 74800100 08001100 1a002300 2d003200 37004900 4f005600 5e006900 70007400 76007800 7a007e00 80008200 84008600 8f009800 a100a600 a900ab00 ad00af00 b400bc00 c500c700 cc00d700 e000e700 ea00f300 f8010101 03010801 10011301 18011a01 1c011e01 23012c01 2e013301 35013701 39013e01 47014901 4e015b01 5e016b01 7d018001 85000000 00000002 01000000 00000000 43000000 00000000 00000000 00000001 87>, "AppleLocale": en_US, "NSInterfaceStyle": macintosh, "MSVLoggingMasterSwitchEnabledKey": 0, "NSLanguages": (
"en-US",
en
), "AppleITunesStoreItemKinds": (
audiobook,
"tv-episode",
booklet,
software,
"software-update",
"itunes-u",
ringtone,
"tv-season",
movie,
mix,
newsstand,
song,
wemix,
tone,
artist,
"podcast-episode",
podcast,
document,
eBook,
album,
"music-video"
), "AppleLanguagesDidMigrate": 9.0, "myNouns": <62706c69 73743030 d4010203 04050653 54582476 65727369 6f6e5824 6f626a65 63747359 24617263 68697665 72542474 6f701200 0186a0af 10100708 15161718 26272e3c 3d4b4c4d 4e4f5524 6e756c6c d3090a0b 0c101457 4e532e6b 6579735a 4e532e6f 626a6563 74735624 636c6173 73a30d0e 0f800280 038004a3 11121380 05800880 0a800f13 68818808 c2d54ae7 13cddfb1 15bd6246 6c13cedf db57f578 a121d719 1a0b1b1c 1d1e1f1f 2122231f 1f567265 67696f6e 55636f6c 6f725269 64547965 61725474 79706554 6e616d65 80068006 80071368 818808c2 d54ae710 03800680 065163d2 28292a2b 5a24636c 6173736e 616d6558 24636c61 73736573 5e436f72 6b537461 73682e57 696e65a2 2c2d5e43 6f726b53 74617368 2e57696e 65584e53 4f626a65 6374d72f 300b3132 33343535 21383935 35567265 67696f6e 55636f6c 6f725269 64547965 61725474 79706554 6e616d65 80098009 800713cd dfb115bd 62466c10 01800980 095161d7 3e3f0b40 41424344 45214748 494a5672 6567696f 6e55636f 6c6f7252 69645479 65617254 74797065 546e616d 65800d80 0e800713 cedfdb57 f578a121 1107c580 0c800b5f 101a696c 69277320 73757065 72206465 6c696369 6f757320 77696e65 5c70696e 6f742067 72696769 6f5a4175 73747261 6c69616e 55776869 7465d228 2950515c 4e534469 6374696f 6e617279 a2522d5c 4e534469 6374696f 6e617279 5f100f4e 534b6579 65644172 63686976 6572d155 5654726f 6f748001 00080011 001a0023 002d0032 0037004a 00500057 005f006a 00710075 00770079 007b007f 00810083 00850087 00900099 00a200b1 00b800be 00c100c6 00cb00d0 00d200d4 00d600df 00e100e3 00e500e7 00ec00f7 0100010f 01120121 012a0139 01400146 0149014e 01530158 015a015c 015e0167 0169016b 016d016f 017e0185 018b018e 01930198 019d019f 01a101a3 01ac01af 01b101b3 01d001dd 01e801ee 01f30200 02030210 02220225 022a0000 00000000 02010000 00000000 00570000 00000000 00000000 00000000 022c>]
Here is when it does not have my data saved:
["AppleLocale": en_US, "NSInterfaceStyle": macintosh, "MSVLoggingMasterSwitchEnabledKey": 0, "NSLanguages": (
"en-US",
en
), "AppleKeyboards": (
"en_US#hw=US;sw=QWERTY",
"emoji#sw=Emoji",
"en_US#hw=US;sw=QWERTY"
), "AppleKeyboardsExpanded": 1, "AppleITunesStoreItemKinds": (
audiobook,
"tv-episode",
booklet,
software,
"software-update",
"itunes-u",
ringtone,
"tv-season",
movie,
mix,
newsstand,
song,
wemix,
tone,
artist,
"podcast-episode",
podcast,
document,
eBook,
album,
"music-video"
), "AddingEmojiKeybordHandled": 1, "AppleLanguagesDidMigrate": 9.0, "AppleLanguages": (
"en-US"
), "ApplePasscodeKeyboards": (
"en_US"
)]
When you're done sending the data to NSUserDefaults you must call synchronize from its instance to be sure that your data was persisted. Otherwise your data may not be persisted in a timely fashion (the app may be terminated before this call is made automatically).
Check the documentation.

iOS decode umlaut &$

I have an example of what I need decoded:
#"f&#252r"
How can I get this decoded to an NSString so it looks like
fūr
I tried a number of things including
[#"f&#252r" stringByDecodingHTMLEntities] > f&#252r
[#"f&#252r" gtm_stringByUnescapingFromHTML] > f&#252r
but no luck.
Thanks!
UPDATE based on vikingosegundo's solution
NSLog(#"möchte decoded to : > %#", [#"möchte" stringByEncodingHTMLEntities] );
NSLog(#"möchte decoded to: > %#", [#"möchte" stringByDecodingHTMLEntities] );
NSLog(#"für decoded to : > %#", [#"für" stringByEncodingHTMLEntities] );
NSLog(#"für decoded to: > %#", [#"für" stringByDecodingHTMLEntities] );
NSLog(#"m&#246chte decoded:%#", [#"m&#246chte" stringByDecodingHTMLEntitiesComma] );
NSLog(#"f&#252r decoded:%#", [#"f&#252r" stringByDecodingHTMLEntitiesComma] );
möchte decoded to : > möchte
möchte decoded to: > möchte
für decoded to : > für
für decoded to: > für
m&#246chte decoded:möchte
f&#252r decoded:für
Note :
stringByEncodingHTMLEntities is from https://github.com/mwaterfall/MWFeedParser/tree/master/Classes
stringByDecodingHTMLEntitiesComma is from vikingosegundo's category.
try
[#"für" stringByDecodingHTMLEntities];
or
[#"für" gtm_stringByUnescapingFromHTML];
(note the ;)
This category also works with out the missing ;.

how to analyze the binary data of these h.264 packets and organize a h.264 stream to decode them use ffmpeg?

Much appreciation to some help with the following issue:
the h.264 packets attached below are received from a decoder,but I am not sure about the details, e.g. the transfer protocol .I've searched some topics similar to this and read the articles of analysis on this topic from the author Cipi and others.Thanks a lot .
but still i can't resolve to analyze the data of these packets .so I issue this problem and hope to get some help.
I'm able to ffmpeg and the first try I've done is to dump this packets to a tmp file and open it use the av_open_inputfile ,but some time the problem is the Codec parameters can't found. so I'm hoping to organize the h264 stream and decode it use the ffmpeg .so How?
Attached:2012-03-21 09:22:37.171 MScope[3006:18f03] received data: <000001ba 66dbf7a3 840100a3 dbfeffff 04354f8b 000001e0 00128c80 0729b6fd e8e1fffc 00000001 09300000 000001e0 00aa8c00 03fffffc 00000001 419a1840 c20837cb ecc1177e e7ead1fc db167e27 a150bf97 dc4736f8 ce12d81f 42fc65ff 607a1f62 89e4f431 5ddfae4f 40fc2bec 5d096c7f 89e6bf0a f27b1077 93d03087 11ebacfc 39e86b1c 27ff2756 97bec73f 37a02370 d7b14b40 7d163f89 d0bd39f9 eb8b1fde 188cefa1 425c97ef 936b5cf5 b1fe7eb1 45f0e638 17382919 1f0c932f f0deab3a ed7ffcbd 3f929f09 735f939f 2e8be16e 7ad01ce3 3e1dbcb0>
2012-03-21 09:22:37.171 MScope[3006:18f03] 220
2012-03-21 09:22:37.202 MScope[3006:18f03] received data: <000001c0 005a8c80 0729b6fd ebcdfffc 1c416a02 d447004f ff16c1bc 2a0eb902 4c185085 04e660cb 3595856a 3eccb10a 761db750 3fb0171e 1c382a62 cf9ff10a ff37e750 55c16fad 22c1933f 03f00878 73521346 4c748898 9d9859a0 a573ada3>
2012-03-21 09:22:37.202 MScope[3006:18f03] 96
2012-03-21 09:22:37.211 MScope[3006:18f03] received data: <000001ba 66dbfc14 040100a3 dbfeffff 04354f8c 000001e0 00128c80 0729b6ff 0501fffc 00000001 09300000 000001e0 00e28c00 03fffffc 00000001 419a1880 c40833d5 a2f9bdfc bde3fac5 08f7ee33 ab447119 07fec5e5 d9fe5b17 0a704b8d 177de307 d7c64c4a cfb5a158 687c2bc4 ec5f327e e85c1872 502e4eef cdcb60df 1363a6e5 df2f27b9 386f746f 2c644bd2 a2c4f7b0 7ae6df7c bd8a4eec ff977df0 e6c0b58f 0b8ff0a7 2f7ae08f b3f4672d ecbe4f75 c37d8ebe 83e6e6bf f7ecc673 76055c57 998beb9b 6079797b c670e740 f87a2ff1 bec150b4 bb04df59 44a718ff 86265adf a12e07da 7ffe5e87 f268058a eac44f27 bf9281f3 f2f6389e b57cda2f d5a4e1cb fd6457f8 fe4d9e7e 6d82cbde f9e00000>
2012-03-21 09:22:37.212 MScope[3006:18f03] 276
2012-03-21 09:22:37.242 MScope[3006:17f03] received data: <000001c0 005a8c80 0729b6ff 07edfffc a83864c2 4e7d4e20 8ae819c6 03724270 7e5730d9 6648f9c8 b2e966d7 bc814c21 06306342 3c05ffe3 5840fcc2 2d2ae65b 1f231694 c8c8b7a2 0ad5080a 4fc3452d 332e9a30 1a3af1e0 b970ad62 a76927c4>
2012-03-21 09:22:37.242 MScope[3006:17f03] 96
2012-03-21 09:22:37.251 MScope[3006:18f03] received data: <000001ba 66dbfc84 840100a3 dbfeffff 04354f8d 000001e0 00128c80 0729b6ff 2121fffc 00000001 09300000 000001e0 00fa8c00 03fffffc 00000001 419a18c0 c608d7ff ffffffff e5f27fd5 5a2aa5f7 3556292a 6e945f5e 967c4757 89efd097 5e847847 d88545e8 7f97b053 75e8ee3b d02a03ec 5f825ec1 a07d80ab e5d0b0a7 7a02fdd8 b88e4d0b 35e2b928 7dc6785b 5c57a176 2158a9b9 ba17c9d0 a5ef61e2 7bdf1379 fac52f0b 7760f4eb 28dffe17 f761f5d8 be2388d1 ecf89eef c9c2f616 80ba12fd 963fbd1d 35797872 c541a025 c547f11d ec1e7e1b a7d7d9d9 cfc27b17 d88dcb7e 23bbf5c1 2632507c abaf572f 7ae4bf24 9579facb e18bd2c6 c2c3ced9 df10fff0 dfa3604b b1fd70d6 c0f5b2fc 56feaf11 d5af86f7 d765f372 76296f17 cf59c4e4 19f0b736 81632000>
2012-03-21 09:22:37.251 MScope[3006:18f03] 300
2012-03-21 09:22:37.282 MScope[3006:17f03] received data: <000001c0 005a8c80 0729b6ff 240dfffc 2e403ec4 2c07bc91 dea5816a fd1335b9 807cd133 4d0a12ac 876514ce 3883236b c0c17c9f 2b93ff26 d83827cc d30bf10a ca0262f5 09cad6ff 81fc2949 90de1ba6 11d98d2a 8dd5e80a e952f45e a4a0e711>
2012-03-21 09:22:37.282 MScope[3006:17f03] 96
2012-03-21 09:22:37.293 MScope[3006:17f03] received data: <000001ba 66dbfcf5 040100a3 dbfeffff 04354f8e 000001bc 0052f5ff 0024400e 484b0001 0c3aa503 2000ffff ffff4112 484b0000 00000000 00000000 00000000 00000024 1be00010 420e0000 60000160 0120111f ff001c20 92c0000c 430a0050 ff00fa03 00fa03ff 7c67884a 000001e0 00128c80 0729b6ff 3d41fffc 00000001 09100000 000001e0 001e8c00 03fffffc 00000001 6742800d 888b40b0 4b420000 0e100002 bf200800 000001e0 000e8c00 03fffffc 00000001 68ce3880 000001e0 253e8c00 03fffffc 00000001 65888008 0002e1f0 87e3e160 001021a1 e0002079 f5eaabd1 80def5ad ec1bc438 f10f7bbc 40904989 1c78adee f726e7dd a4dcfbbc 9b93bcf9 fff870a4 43cb65ed e5f97aff 08c7f510 3ce7c6de 3c3f72b2 f76f9cd1 fe3c3ff5 7103e5e7 3ebd7aae fdffffd4 5d6aafb7 d576f1f0 ffb8ac43 e99cf6f6 fd755d42 d84e2239 fff2c357 bd6b08e0 016317b0 91a8eb7a 18bec15f be000e13 b8cd2ed1 88a11360 250fd11b aa269986 2dffe034 9de244ca 1f4a2bf6 a03404c2 8aebc2cd bb012c7b 08cf5936 cd290fff 01a6ed52 fce1b482 ff6a58f7 3019ed40 4fabc400 0080b59a 5045138e 2394b709 5cfb905d 17771f4c ed199f0e 400021c6 6a934a0d edfbe012 5cb14bf0 06288cd2 dff7fe01 c3800877 0249cb92 6ca17482 1ffb02b8 bf314562 1e93d5e9 0226b833 bbeef4b9 c0e0409d c66977d8 8a1136f7 087e88dd 43e99852 4dfff684 ef122650 fa4105fe d8078128 a2a01b3a 229f9738 089c4a96 c49b5305 822612c5 b2529a5f f61144e3 88e52587 87f9f7a0 5d1f05d2 6cc4327f 7c3c30ff 0ef6b1ee 272da862 4f578092 c2eff5d9 67901b5a 3d40370a d561de23 7d7fd7fb e3168a50 5ebbca21 092c7800 1b046172 c0070995 3a84bd87 512fdfbc 62f18a0b b79742b1 86f863d1 0ae997ed 8bffff0d 0940abf5 30ea6ade 6f18b652 82f4de63 95e4ecb8 6c0001bb 419926c6 b00fb1f9 89849d59 bffaffd1 f1e11806 0170158f 6119ab7d b34a41bf fed0ddaa 5f9436b8 b7fed6b1 ee6023da 81e64f57 88001000 40213204 09d46693 7d88a3ac 5ee10fd3 0ba87d2b 0a49bffe b1a80854 dea31059 bb56201f a2351d89 c59ffeff 6c01711a a4d282e3 beff7de1 778a5f80 2484fa95 4e4d83cb 8f1034cb 96340f64 7f64d8a8 b7ad9651 712ec6b1 67ffbfd0 4ba7f00f 0fdcb540 05717065 7b5465b4 25e60c01 c7e2b86d a8ca7269 e00a1eaa ca98c1ef 60c6f885 ab1113ff d3afe21e aac1b2b2 dc9d7ffc 534cf3e6 3f15c36d 5653938f 000f0361 2ab4deb7 5b097f7e 7a000240 6b40cf05 de43d558 3655e5b9 3af19674 020bd93a 4dbba3b7 ef8d8895 5b87c403 805f913a 8cb26fb1 147589dc 21fa6175 0fa56149 2fffda13 bc49b285 d20827f6 c0783510 4402e744 51f2ed09 de24d942 eb887fec 0ae2f4ce 7310549e af481328 c3b79eff 0b9c0dd8 4e2618ee 5258785f 9f7a0ba2 e1f5f657 3277c648 23245c04 c83a92c4 9b530782 641d4962 4da9bf5b f807e10d c04ccc9c 62307fac 29a60001 8046932c 09820010 51505e80 01d0f556 54c60b7b 4513e216 a8446fff 4fefada2 412adcc3 956f1951 e7000081 c300014d 9121bf46 9d67e440 007022cf 9d8c0008 1452e998 1a47867e c2d45b16 f3626bf8 43e01b87 58003509 94764dbf 3e907092 79ae081d 31c4bb46 69e737dd 8b1ea663 9f9045bc d5e02801 616c9ba6 714f53f1 bfffa004 d05e5a18 d35d4600 01b0451b 2c0ac2f8 ec731444 9eaf61c0 3c21df00 041bba2e 4d9c2cd5 8d647806 001c191a f217aac8 bf6ebf26 0661e728 b3ad2c70 d6b801d0 8ab2d607 7567a0dc 18545ea1 3a9c24d3 ef3480d0 859e766e d89b7002 87ea32be cbc01e38 3b8904b6 85c20ab7 ea331800 20068064 9801f63f 3131a396 37dd84c0 e83aa118 6505d9e6 b2607710 7562f167 abd80098 e2ae6dc9 63acb7ff bcb00043 d2949eb4 2d059ff7 c806010f 0c2fa6c1 a946df28 843a4f7f fc068119 f17063a7 f9e96bac 960c44ce 2350b376 bc896424 4f57a775 00617aac 1f6eb2dc 8c683dac 8c82e729 887376b8 b436405c 9add43ae 1ede44b2 1227efd3 abf8059b 0474de09 7774ad25 8131c45d 5b16ba99 7ffbc1ab cc000300 8d2e5bf0 f8618760 c002c4ca 9c33af62 d2fadf80 0110fd46 55d97ec8 bea68d21 b7565455 e9c31aa0 65af0015 2d3ce021 456810b2 51944db3 fddeee9b 8b54196e 65fb65dc 07e38601 c001f1e8 632947b5 69082fff d81bb54f 9425b896 bfed6b1e a6066ad0 34a9eaf1 80008004 90527a04 09d44593 3d88a32c 4ee10fd3 1d482d2b 08497ffe f45f288b dbbe3dc9 154f31e8 8ea9afda 2a8200b8 8b47d287 c77bfefb 82ef15fe 0107f295 461ff1ad 4b09b3ee 64c26788 e3918de0 bbc57f80 41bca551 87fc3186 3d4b77f2 e977ff80 601c3db8 5e1d8e62 8893d5e0 521e8773 9ca729ea f000593b c49b28f6 e737f605 717a6739 88729eaf 48132883 b79deecb 9c49a8e0 263b1c86 3a0ea702 613d686a d07510d3 221e6870 1320a84a bcda983c 4120aa4b 126d4ccb 35da8dfc badfff00 c02e02b1 e8632945 b569082f ffde63d1 1d5375da 2fc1a811 ca4001f5 183f6d77 087e98ea 41695842 4bfff07b 70bc3b1c c5339eaf 0290f42b 9ce517cf 57acc838 37e1b78e dbec6594 e851312a 4cbffde3 0cd065f4 b38098ec 7208b41d 4e04c27a 50b6a0ea c4d03ff4 b7f0e002 1d4002c9 de24d947 b739bfb0 2b8bf239 ccc2f9ea f4813288 3b79deec b9c2d600 813a88b7 cf6228cb 3f7087e9 8ea41695 8424bfff 684ef34d 942eb9cf fdb01e09 441101f1 a7ffc5ce 02641509 579b5305 82641d89 54fa6972 f246c273 20677212 a342fcfb d0be5c3e b6c8e64e eb9f8e9a 5ba3b0c3 ffc39469 702e5d36 7d68ec13 e9537ffd 6a12c196 85fd7eb5 f7ffff7d f5f76d55 bffffeeb aad5557a ac2d80d7 6472c7ff 65eaf7ad 65e4ce44 4e6fd87c 03feb6a4 b07ee538 03678a66 d3c2adda 560ef825 919bd03f 6150cc6c a8b3f229 3d8e032c 6aa5fcc3 182ce001 00e18006 a7ec5187 6a65f6d2 7cf0fd38 4c3c81b9 a203cd47 dc5ef2cf b76badc4 e1b70631 5427809e 70add3da 573a5f08 b596b08e ae9ad931 6165c21f 99813f89 af0b609c 2990c1be 21ffaaac 1afd1715 34f05304 e13c0377 53d3ff8b e373bacf 1763b1b8 4f01d3f2 e2d47c6d f4338259 f6bb7615 71508fa3 b1560108 61fea0b7 c32c87f7 b8754cc9 5ae6b0ed 3322ac3c 21ff55fc 9c0ebf07 cd31ba9d 73778a3a 641b29d1 aa27c103 1a51fa81 4cd09e53 b47dbed9 f7fc6334 27b097d2 aeb4886b fc14c3b2 84f1e69d 2319adfa e32e33fe 3540c8a1 3c8ce75b fe0cd2de 7e67c0e9 77387d78 7ffea2c2 255307be cf9d5791 8ae3e1ff 797d34cb cbe6b6e5 545f01ff fd78a6f5 8baaa88f 52fc5582 e921ffff bd5755cd d7955c21 f080807e bd570ed1 a9c00080 de46a1a8 3c952d1c bf5dbffe 018075d5 753662b5 16773057 1f20ef34 2e9a7b65 dffe01f0 415860ce 9ea028b4 5e696823 9b3ffef2 c3e001f0 8781f698 5d0ca532 ca4669f6 45b68cac 8c879acf 58047991 d83bf4d3 eb460597 0dd82063 4ad7f00f ffeba517 7aaae76a 8b9daad4 b4135aa5 33972b8c ff77f01a 2196a9f7 a13c0084 c4b72067 ee45d6dd 84ece8ab 20896587 7a29684d 34fdcfb5 b45572c3 a3596756 3fffea01 d6ee1470 73f23c40 414c7976 28f9af2f 8b8310df d9096e32 d0c25dfc 7ffb9061 3a4119f9 66583fd4 a57b5ad0 2faad4b4 388db69e e6231fff f5870306 d68bc10d 7884883a 3774d25f f4c1dc83 d96881aa 6bdff0ff acd5e94f a3ac1c70 4f731594 e4419a7e 4a9d019b ffff960e b7a656aa f4c52994 d67e3047 8963414c 2a1b4234 fab9bb44 6bdfc3ff 8631dbc6 90439720 b987ffff eb2bfac7 9eb16412 3ffffcd5 5d5557a7 37ffff75 55d5757a a7ac38a7 ab091476 c0210843 0f99901d 8ed04273 fd6ee0a6 10d35a20 abaf126b 63df37b3 36ce3462 7379aad9 6efbf4ff fe001f8e 8657d1df 8d8eadf8 7951d85a a8dcb6d7 b9203b51 9ddea6e1 6296ba69 b9d8937a 2e4b15c5 d9f957a7 1f100fff d70e7890 0677c46a 2315fa73 41f538a8 7fb251ef e0e4c3d1 563c5a98 eb328853 30607ef4 3f81fd72 1e6ae3bf fff85ebd 00cd260e ea58a46f 9320d59a 4cc60a32 2e5e27f5 63080d95 9e843194 1fffebff>
This is the standard h.264 stream,with no fragmentation NAL unit.
the NAL unit begins with three bytes 0x00000001,and the NAL unit type detected :
00000001 09 :Access Unit Delimiter,the following data is not required for decoding
00000001 41 :Coded Slice.P or B frames following with the IDR frame;
00000001 67 and 00000001 68: SPS and PPS,the Configuration Info for h.264.
00000001 65: IDR frame
with the undefined header of these packets,firstly i'm confused of the approach to
deal with the stream.With ffmpeg,i extract these NAL unit ,beginning with the IDR frame,
following with the slices frame data ,and decode them successfully to AVFrame data.

Resources