Skip to content
This repository has been archived by the owner on Aug 4, 2019. It is now read-only.

Commit

Permalink
Add additional enums from updated toxav.h
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuongv committed Jun 29, 2015
1 parent 1d9cf0d commit 08f8199
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 39 deletions.
14 changes: 7 additions & 7 deletions Classes/Private/Manager/Submanagers/OCTSubmanagerCalls.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,19 @@ - (void)updateCall:(OCTCall *)call withState:(OCTToxAVCallState)state
{
BOOL sendingAudio, sendingVideo, receivingAudio, receivingVideo;

if (state & OCTToxAVCallStateReceivingAudio) {
if (state & OCTToxAVFriendCallStateReceivingAudio) {
receivingAudio = YES;
}

if (state & OCTToxAVCallStateReceivingVideo) {
if (state & OCTToxAVFriendCallStateReceivingVideo) {
receivingVideo = YES;
}

if (state & OCTToxAVCallStateSendingAudio) {
if (state & OCTToxAVFriendCallStateSendingAudio) {
sendingAudio = YES;
}

if (state & OCTToxAVCallStateSendingVideo) {
if (state & OCTToxAVFriendCallStateSendingVideo) {
sendingVideo = YES;
}

Expand Down Expand Up @@ -273,7 +273,7 @@ - (void)toxAV:(OCTToxAV *)toxAV callStateChanged:(OCTToxAVCallState)state friend

OCTCallStatus status = call.status;

if ((state & OCTToxAVCallStateFinished) || (state & OCTToxAVCallStateError)) {
if ((state & OCTToxAVFriendCallStateFinished) || (state & OCTToxAVFriendCallStateError)) {

OCTMessageCallEvent event = (status != OCTCallStatusActive) ? OCTMessageCallEventUnanswered : OCTMessageCallEventAnswered;

Expand All @@ -296,12 +296,12 @@ - (void)toxAV:(OCTToxAV *)toxAV callStateChanged:(OCTToxAVCallState)state friend

- (void)toxAV:(OCTToxAV *)toxAV audioBitRateChanged:(OCTToxAVAudioBitRate)bitrate stable:(BOOL)stable friendNumber:(OCTToxFriendNumber)friendNumber
{
// Lower bitrate if unstable?
if (! stable) {}
}

- (void)toxAV:(OCTToxAV *)toxAV videoBitRateChanged:(OCTToxAVVideoBitRate)bitrate friendNumber:(OCTToxFriendNumber)friendNumber stable:(BOOL)stable
{
// Lower bitrate if unstable?
if (! stable) {}
}

- (void) toxAV:(OCTToxAV *)toxAV
Expand Down
29 changes: 16 additions & 13 deletions Classes/Private/Wrapper/OCTToxAV.m
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ - (void)fillError:(NSError **)error withCErrorSendFrame:(TOXAV_ERR_SEND_FRAME)cE
code = OCTToxAVErrorSendFrameInvalid;
failureReason = @"One of the frame parameters was invalid. E.g. the resolution may be too small or too large, or the audio sampling rate may be unsupported";
break;
case TOXAV_ERR_SEND_FRAME_BIT_RATE_NOT_SET:
code = OCTToxAVErrorFrameBitrateWasNotSet;
failureReason = @"Bit rate for this payload type was not set up.";
case TOXAV_ERR_SEND_FRAME_RTP_FAILED:
code = OCTToxAVErrorSendFrameRTPFailed;
failureReason = @"Failed to push frame through rtp interface";
Expand Down Expand Up @@ -542,7 +545,7 @@ void callIncomingCallback(ToxAV *cToxAV,

void callStateCallback(ToxAV *cToxAV,
uint32_t friendNumber,
enum TOXAV_CALL_STATE cState,
enum TOXAV_FRIEND_CALL_STATE cState,
void *userData)
{
OCTToxAV *toxAV = (__bridge OCTToxAV *)userData;
Expand All @@ -553,23 +556,23 @@ void callStateCallback(ToxAV *cToxAV,

OCTToxAVCallState state = 0;

if (cState & TOXAV_CALL_STATE_ERROR) {
state |= OCTToxAVCallStateError;
if (cState & TOXAV_FRIEND_CALL_STATE_ERROR) {
state |= OCTToxAVFriendCallStateError;
}
if (cState & TOXAV_CALL_STATE_FINISHED) {
state |= OCTToxAVCallStateFinished;
if (cState & TOXAV_FRIEND_CALL_STATE_FINISHED) {
state |= OCTToxAVFriendCallStateFinished;
}
if (cState & TOXAV_CALL_STATE_SENDING_A) {
state |= OCTToxAVCallStateSendingAudio;
if (cState & TOXAV_FRIEND_CALL_STATE_SENDING_A) {
state |= OCTToxAVFriendCallStateSendingAudio;
}
if (cState & TOXAV_CALL_STATE_SENDING_V) {
state |= OCTToxAVCallStateSendingVideo;
if (cState & TOXAV_FRIEND_CALL_STATE_SENDING_V) {
state |= OCTToxAVFriendCallStateSendingVideo;
}
if (cState & TOXAV_CALL_STATE_RECEIVING_A) {
state |= OCTToxAVCallStateReceivingAudio;
if (cState & TOXAV_FRIEND_CALL_STATE_RECEIVING_A) {
state |= OCTToxAVFriendCallStateReceivingAudio;
}
if (cState & TOXAV_CALL_STATE_RECEIVING_V) {
state |= OCTToxAVCallStateReceivingVideo;
if (cState & TOXAV_FRIEND_CALL_STATE_RECEIVING_V) {
state |= OCTToxAVFriendCallStateReceivingVideo;
}

if ([toxAV.delegate respondsToSelector:@selector(toxAV:callStateChanged:friendNumber:)]) {
Expand Down
17 changes: 11 additions & 6 deletions Classes/Public/Wrapper/OCTToxAVConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,34 @@ typedef NS_OPTIONS(NSInteger, OCTToxAVCallState) {
* transitions can occur for the call. This call state will never be triggered
* in combination with other call states.
*/
OCTToxAVCallStateError = 1 << 0,
OCTToxAVFriendCallStateError = 1 << 0,

/**
* The call has finished. This is the final state after which no more state
* transitions can occur for the call. This call state will never be
* triggered in combination with other call states.
*/
OCTToxAVCallStateFinished = 1 << 1,
OCTToxAVFriendCallStateFinished = 1 << 1,

/**
* The flag that marks that friend is sending audio.
*/
OCTToxAVCallStateSendingAudio = 1 << 2,
OCTToxAVFriendCallStateSendingAudio = 1 << 2,

/**
* The flag that marks that friend is sending video.
*/
OCTToxAVCallStateSendingVideo = 1 << 3,
OCTToxAVFriendCallStateSendingVideo = 1 << 3,

/**
* The flag that marks that friend is receiving audio.
*/
OCTToxAVCallStateReceivingAudio = 1 << 4,
OCTToxAVFriendCallStateReceivingAudio = 1 << 4,

/**
* The flag that marks that friend is receiving video.
*/
OCTToxAVCallStateReceivingVideo = 1 << 5,
OCTToxAVFriendCallStateReceivingVideo = 1 << 5,
};

/*******************************************************************************
Expand Down Expand Up @@ -235,6 +235,11 @@ typedef NS_ENUM(NSInteger, OCTToxAVErrorSendFrame) {
*/
OCTToxAVErrorSendFrameInvalid,

/**
* Bit rate for this payload type was not set up.
*/
OCTToxAVErrorFrameBitrateWasNotSet,

/**
* Failed to push frame through rtp interface.
*/
Expand Down
8 changes: 4 additions & 4 deletions objcToxTests/OCTSubmanagerCallsTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ - (void)testCallStateReceiveFinished
}];

OCTToxAVCallState state;
state |= OCTToxAVCallStateFinished;
state |= OCTToxAVFriendCallStateFinished;

[self.callManager toxAV:nil callStateChanged:state friendNumber:89];

Expand Down Expand Up @@ -219,7 +219,7 @@ - (void)testFriendAnsweredCall
}];

OCTToxAVCallState state;
state |= OCTToxAVCallStateReceivingVideo;
state |= OCTToxAVFriendCallStateReceivingVideo;

[self.callManager toxAV:nil callStateChanged:state friendNumber:92];

Expand Down Expand Up @@ -337,8 +337,8 @@ - (void)testCallStateChanged

OCTToxAVCallState state;

state |= OCTToxAVCallStateReceivingAudio;
state |= OCTToxAVCallStateReceivingVideo;
state |= OCTToxAVFriendCallStateReceivingAudio;
state |= OCTToxAVFriendCallStateReceivingVideo;

[self.callManager toxAV:nil callStateChanged:state friendNumber:111];

Expand Down
18 changes: 9 additions & 9 deletions objcToxTests/OCTToxAVTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ - (void)tearDown

self.tox = nil;
self.toxAV = nil;

refToSelf = NULL;

[super tearDown];
Expand Down Expand Up @@ -332,38 +332,38 @@ - (void)testReceiveCallback
- (void)testCallStateCallback
{
[self makeTestCallbackWithCallBlock:^{
callStateCallback(NULL, 1, TOXAV_CALL_STATE_RECEIVING_A | TOXAV_CALL_STATE_SENDING_A, (__bridge void *)self.toxAV);
callStateCallback(NULL, 1, TOXAV_FRIEND_CALL_STATE_RECEIVING_A | TOXAV_FRIEND_CALL_STATE_SENDING_A, (__bridge void *)self.toxAV);
} expectBlock:^(id<OCTToxAVDelegate> delegate) {
OCTToxFriendNumber friendNumber = 1;
OCMExpect([self.toxAV.delegate toxAV:self.toxAV
callStateChanged:OCTToxAVCallStateReceivingAudio | OCTToxAVCallStateSendingAudio
callStateChanged:OCTToxAVFriendCallStateReceivingAudio | OCTToxAVFriendCallStateSendingAudio
friendNumber:friendNumber]);
}];

[self makeTestCallbackWithCallBlock:^{
callStateCallback(NULL, 1, TOXAV_CALL_STATE_SENDING_A, (__bridge void *)self.toxAV);
callStateCallback(NULL, 1, TOXAV_FRIEND_CALL_STATE_SENDING_A, (__bridge void *)self.toxAV);
} expectBlock:^(id<OCTToxAVDelegate> delegate) {
OCTToxFriendNumber friendNumber = 1;
OCMExpect([self.toxAV.delegate toxAV:self.toxAV
callStateChanged:OCTToxAVCallStateSendingAudio
callStateChanged:OCTToxAVFriendCallStateSendingAudio
friendNumber:friendNumber]);
}];

[self makeTestCallbackWithCallBlock:^{
callStateCallback(NULL, 1, TOXAV_CALL_STATE_ERROR, (__bridge void *)self.toxAV);
callStateCallback(NULL, 1, TOXAV_FRIEND_CALL_STATE_ERROR, (__bridge void *)self.toxAV);
} expectBlock:^(id<OCTToxAVDelegate> delegate) {
OCTToxFriendNumber friendNumber = 1;
OCMExpect([self.toxAV.delegate toxAV:self.toxAV
callStateChanged:OCTToxAVCallStateError
callStateChanged:OCTToxAVFriendCallStateError
friendNumber:friendNumber]);
}];

[self makeTestCallbackWithCallBlock:^{
callStateCallback(NULL, 1, TOXAV_CALL_STATE_RECEIVING_A | TOXAV_CALL_STATE_SENDING_A | TOXAV_CALL_STATE_SENDING_V, (__bridge void *)self.toxAV);
callStateCallback(NULL, 1, TOXAV_FRIEND_CALL_STATE_RECEIVING_A | TOXAV_FRIEND_CALL_STATE_SENDING_A | TOXAV_FRIEND_CALL_STATE_SENDING_A, (__bridge void *)self.toxAV);
} expectBlock:^(id<OCTToxAVDelegate> delegate) {
OCTToxFriendNumber friendNumber = 1;
OCMExpect([self.toxAV.delegate toxAV:self.toxAV
callStateChanged:OCTToxAVCallStateReceivingAudio | OCTToxAVCallStateSendingAudio | OCTToxAVCallStateSendingVideo
callStateChanged:OCTToxAVFriendCallStateReceivingAudio | OCTToxAVFriendCallStateSendingAudio | OCTToxAVFriendCallStateSendingVideo
friendNumber:friendNumber]);
}];
}
Expand Down

0 comments on commit 08f8199

Please sign in to comment.