-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathPacketAudioBuffer.m
68 lines (52 loc) · 1.68 KB
/
PacketAudioBuffer.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// PacketAudioBuffer.m
// Snap
//
// Created by Abdullah Bakhach on 8/28/12.
// Copyright (c) 2012 Hollance. All rights reserved.
//
#import "PacketAudioBuffer.h"
#import "NSData+SnapAdditions.h"
@implementation PacketAudioBuffer
@synthesize audioBufferData = _audioBufferData;
@synthesize packetID = _packetID;
@synthesize packetNumber = _packetNumber;
@synthesize packetBytesFilled = _packetBytesFilled;
@synthesize packetDescriptionsBytesFilled =_packetDescriptionsBytesFilled;
@synthesize packetDescriptionsData = _packetDescriptionsData;
@synthesize totalSize = _totalSize;
+ (id)packetWithData:(NSData *)data
{
int totalSize = [data length];
int packetNumber = [data rw_int32AtOffset:4];
return [[self class] packetWithAudioBuffer:data
totalSize:totalSize
packetNumber:packetNumber
];
}
+ (id)packetWithAudioBuffer:(NSData *)data
totalSize:(UInt32)totalSize
packetNumber:(UInt32)packetNumber
{
return [[[self class] alloc] initWithAudioBufferData:data
totalSize:totalSize
packetNumber:packetNumber
];
}
- (id)initWithAudioBufferData:(NSData *)data
totalSize:(UInt32)totalSize
packetNumber:(UInt32)packetNumber
{
if ((self = [super initWithType:PacketTypeAudioBuffer]))
{
self.audioBufferData = data;
self.totalSize = totalSize;
self.packetNumber = packetNumber;
}
return self;
}
- (void)addPayloadToData:(NSMutableData *)data
{
[data rw_appendString:self.audioBufferData];
}
@end