1467 } |
1472 } |
1468 void UT_CRtpAPI::SRTPMasterKeyStaleEvent(const CSRTPStream& /*aStream*/) |
1473 void UT_CRtpAPI::SRTPMasterKeyStaleEvent(const CSRTPStream& /*aStream*/) |
1469 { |
1474 { |
1470 |
1475 |
1471 } |
1476 } |
|
1477 |
|
1478 void UT_CRtpAPI::ReadyToSendRtpPacket( TRtpId /*aTranStreamId*/, TPtr8 &/*aPacket*/ ) |
|
1479 { |
|
1480 // RTP Packet Callback received |
|
1481 iIsCallBackReceived = ETrue; |
|
1482 } |
|
1483 |
|
1484 |
|
1485 void UT_CRtpAPI::UT_CRtpAPI_RegisterRtpPostProcessingObserverL( ) |
|
1486 { |
|
1487 TInt result(KErrNone); |
|
1488 TRtpSdesParams params; |
|
1489 |
|
1490 result = iRtpAPI->OpenL( params, NULL, NULL, NULL ); |
|
1491 EUNIT_ASSERT(result==KErrNone); |
|
1492 |
|
1493 TRequestStatus status; |
|
1494 result = iRtpAPI->StartConnection( status, KDefaultIap2 ); // KDefaultIap |
|
1495 RTP_EUNIT_ASSERT_EQUALS ( result, KErrNone ); |
|
1496 // Wait until the connection is really up |
|
1497 User::WaitForRequest( status ); |
|
1498 |
|
1499 //create session |
|
1500 TCreateSessionParams sessionParams; |
|
1501 sessionParams.iPriority = TCreateSessionParams::EPriorityStandard; |
|
1502 sessionParams.iSocketBufSize = KSocketBufSize; |
|
1503 TUint port( 5000 ); |
|
1504 TBool enableRtcp( EFalse ); |
|
1505 TRtcpParams rtcpParams; |
|
1506 rtcpParams.iRtcpFraction = 0.10; |
|
1507 rtcpParams.iRtcpTimeOut = 0; |
|
1508 rtcpParams.iSessionBWidth = 32000; |
|
1509 |
|
1510 TRtpId error( KNullId ); |
|
1511 error = iRtpAPI->CreateSessionL( sessionParams, |
|
1512 port, |
|
1513 enableRtcp, |
|
1514 &rtcpParams ); |
|
1515 RTP_EUNIT_ASSERT_RTP_ID( error ); |
|
1516 |
|
1517 TRcvStreamParams recvparams; |
|
1518 recvparams.iPayloadType = 0; |
|
1519 |
|
1520 TRtpId error2( KNullId ); |
|
1521 TInt err( KErrNone ); |
|
1522 error2 = iRtpAPI->CreateReceiveStreamL( error /*session id*/, recvparams ); |
|
1523 RTP_EUNIT_ASSERT_RTP_ID ( error2 ); |
|
1524 |
|
1525 |
|
1526 err = iRtpAPI->RegisterRtpPostProcessingObserver( error, *this ); |
|
1527 EUNIT_ASSERT ( err == KErrNone ) |
|
1528 } |
|
1529 |
|
1530 |
|
1531 void UT_CRtpAPI::UT_CRtpAPI_SendRtpPacketWithCSRCL() |
|
1532 { |
|
1533 TInt result(KErrNone); |
|
1534 TRtpSdesParams params; |
|
1535 |
|
1536 result = iRtpAPI->OpenL( params, NULL, NULL, NULL ); |
|
1537 RTP_EUNIT_ASSERT_EQUALS(result, KErrNone); |
|
1538 |
|
1539 TRequestStatus status; |
|
1540 result = iRtpAPI->StartConnection( status, KDefaultIap ); // KDefaultIap |
|
1541 RTP_EUNIT_ASSERT_EQUALS ( result, KErrNone ); |
|
1542 // Wait until the connection is really up |
|
1543 User::WaitForRequest( status ); |
|
1544 |
|
1545 //create session |
|
1546 TCreateSessionParams sessionParams; |
|
1547 sessionParams.iPriority = TCreateSessionParams::EPriorityStandard; |
|
1548 sessionParams.iSocketBufSize = KSocketBufSize; |
|
1549 TUint port( 5000 ); |
|
1550 TBool enableRtcp( EFalse ); |
|
1551 TRtcpParams rtcpParams; |
|
1552 rtcpParams.iRtcpFraction = 0.10; |
|
1553 rtcpParams.iRtcpTimeOut = 0; |
|
1554 rtcpParams.iSessionBWidth = 32000; |
|
1555 |
|
1556 TRtpId error( KNullId ); |
|
1557 error = iRtpAPI->CreateSessionL( sessionParams, |
|
1558 port, |
|
1559 enableRtcp, |
|
1560 &rtcpParams ); |
|
1561 RTP_EUNIT_ASSERT_RTP_ID( error ); |
|
1562 |
|
1563 TTranStreamParams transparams; |
|
1564 transparams.iPayloadType = 0; |
|
1565 TRtpSSRC ssrc( 0 ); |
|
1566 |
|
1567 TInt err( KErrNone ); |
|
1568 err = iRtpAPI->RegisterRtpPostProcessingObserver( error, *this ); |
|
1569 EUNIT_ASSERT ( err == KErrNone ) |
|
1570 |
|
1571 |
|
1572 err = iRtpAPI->CreateTransmitStreamL( error /*session id*/, transparams, ssrc ); |
|
1573 RTP_EUNIT_ASSERT_RTP_ID ( err ); |
|
1574 |
|
1575 |
|
1576 TRtpSendHeader header; |
|
1577 header.iHeaderExtension = NULL; |
|
1578 header.iMarker = 0; |
|
1579 header.iPadding = 0; |
|
1580 header.iPayloadType = 0; |
|
1581 header.iTimestamp = 10; |
|
1582 |
|
1583 HBufC8* data = HBufC8::NewLC(KLength); |
|
1584 data->Des().Copy(KHello); |
|
1585 CleanupStack::Pop(data); |
|
1586 |
|
1587 TRtpSendPktParams *headerinfo = new(ELeave) TRtpSendPktParams(header); |
|
1588 headerinfo->iTranStreamId = err; |
|
1589 headerinfo->iPayloadData.Set(data->Des()); |
|
1590 |
|
1591 const TUint KArrayGranularity = 15; |
|
1592 |
|
1593 CArrayFixFlat<TUint32>* fix; |
|
1594 fix = new(ELeave) CArrayFixFlat<TUint32>(KArrayGranularity); |
|
1595 |
|
1596 fix->AppendL(123456); |
|
1597 fix->AppendL(999999); |
|
1598 |
|
1599 TInt error2( KErrNone ); |
|
1600 iIsCallBackReceived = EFalse; |
|
1601 // Try sending synchronously with Csrc |
|
1602 error2 = iRtpAPI->SendRtpPacket(*headerinfo, fix->Array()); |
|
1603 RTP_EUNIT_ASSERT_EQUALS ( error2, KErrNone ); |
|
1604 |
|
1605 CRtpSession* rtpSession = iRtpAPI->iManager->GetSession( err ); |
|
1606 User::WaitForRequest( rtpSession->iCommNet->iSender[ERTPPort]->iStatus ); |
|
1607 rtpSession->iCommNet->iSender[ERTPPort]->RunL(); |
|
1608 rtpSession->iCommNet->iSender[ERTPPort]->iStatus = TRequestStatus(); |
|
1609 EUNIT_ASSERT(iIsCallBackReceived == ETrue); |
|
1610 |
|
1611 iIsCallBackReceived = EFalse; |
|
1612 // Try sending asynchronously with CSRC |
|
1613 headerinfo->iStatus = &status; |
|
1614 error2 = iRtpAPI->SendRtpPacket(*headerinfo, fix->Array()); |
|
1615 RTP_EUNIT_ASSERT_EQUALS ( error2, KErrNone ); |
|
1616 EUNIT_ASSERT( KRequestPending == status.Int() ); |
|
1617 User::WaitForRequest( rtpSession->iCommNet->iSender[ERTPPort]->iStatus ); |
|
1618 rtpSession->iCommNet->iSender[ERTPPort]->RunL(); |
|
1619 rtpSession->iCommNet->iSender[ERTPPort]->iStatus = TRequestStatus(); |
|
1620 User::WaitForRequest( status ); |
|
1621 EUNIT_ASSERT( KErrNone == status.Int() ); |
|
1622 // Is call back received check |
|
1623 EUNIT_ASSERT(iIsCallBackReceived == ETrue); |
|
1624 |
|
1625 iIsCallBackReceived = EFalse; |
|
1626 // Try sending asynchronously, specifying the sequence number with CSRC |
|
1627 TRtpSequence seqNum = 42; |
|
1628 headerinfo->iSequenceNum = &seqNum; |
|
1629 error2 = iRtpAPI->SendRtpPacket(*headerinfo, fix->Array()); |
|
1630 RTP_EUNIT_ASSERT_EQUALS ( error2, KErrNone ); |
|
1631 EUNIT_ASSERT( KRequestPending == status.Int() ); |
|
1632 User::WaitForRequest( rtpSession->iCommNet->iSender[ERTPPort]->iStatus ); |
|
1633 rtpSession->iCommNet->iSender[ERTPPort]->RunL(); |
|
1634 rtpSession->iCommNet->iSender[ERTPPort]->iStatus = TRequestStatus(); |
|
1635 User::WaitForRequest( status ); |
|
1636 EUNIT_ASSERT( KErrNone == status.Int() ); |
|
1637 EUNIT_ASSERT(iIsCallBackReceived == ETrue); |
|
1638 |
|
1639 delete fix; |
|
1640 delete headerinfo; |
|
1641 delete data; |
|
1642 } |
|
1643 |
|
1644 |
|
1645 void UT_CRtpAPI::UT_CRtpAPI_UnregisterRtpPostProcessingObserverL( ) |
|
1646 { |
|
1647 TInt result(KErrNone); |
|
1648 TRtpSdesParams params; |
|
1649 |
|
1650 result = iRtpAPI->OpenL( params, NULL, NULL, NULL ); |
|
1651 EUNIT_ASSERT(result==KErrNone); |
|
1652 |
|
1653 TRequestStatus status; |
|
1654 result = iRtpAPI->StartConnection( status, KDefaultIap2 ); // KDefaultIap |
|
1655 RTP_EUNIT_ASSERT_EQUALS ( result, KErrNone ); |
|
1656 // Wait until the connection is really up |
|
1657 User::WaitForRequest( status ); |
|
1658 |
|
1659 //create session |
|
1660 TCreateSessionParams sessionParams; |
|
1661 sessionParams.iPriority = TCreateSessionParams::EPriorityStandard; |
|
1662 sessionParams.iSocketBufSize = KSocketBufSize; |
|
1663 TUint port( 5000 ); |
|
1664 TBool enableRtcp( EFalse ); |
|
1665 TRtcpParams rtcpParams; |
|
1666 rtcpParams.iRtcpFraction = 0.10; |
|
1667 rtcpParams.iRtcpTimeOut = 0; |
|
1668 rtcpParams.iSessionBWidth = 32000; |
|
1669 |
|
1670 TRtpId error( KNullId ); |
|
1671 error = iRtpAPI->CreateSessionL( sessionParams, |
|
1672 port, |
|
1673 enableRtcp, |
|
1674 &rtcpParams ); |
|
1675 RTP_EUNIT_ASSERT_RTP_ID( error ); |
|
1676 |
|
1677 TRcvStreamParams recvparams; |
|
1678 recvparams.iPayloadType = 0; |
|
1679 |
|
1680 TRtpId error2( KNullId ); |
|
1681 TInt err( KErrNone ); |
|
1682 error2 = iRtpAPI->CreateReceiveStreamL( error /*session id*/, recvparams ); |
|
1683 RTP_EUNIT_ASSERT_RTP_ID ( error2 ); |
|
1684 |
|
1685 TTranStreamParams transparams; |
|
1686 transparams.iPayloadType = 0; |
|
1687 TRtpSSRC ssrc( 0 ); |
|
1688 |
|
1689 err = iRtpAPI->RegisterRtpPostProcessingObserver( error, *this ); |
|
1690 EUNIT_ASSERT ( err == KErrNone ) |
|
1691 |
|
1692 err = iRtpAPI->CreateTransmitStreamL( error /*session id*/, transparams, ssrc ); |
|
1693 RTP_EUNIT_ASSERT_RTP_ID ( err ); |
|
1694 |
|
1695 |
|
1696 TRtpSendHeader header; |
|
1697 header.iHeaderExtension = NULL; |
|
1698 header.iMarker = 0; |
|
1699 header.iPadding = 0; |
|
1700 header.iPayloadType = 0; |
|
1701 header.iTimestamp = 10; |
|
1702 |
|
1703 HBufC8* data = HBufC8::NewLC(KLength); |
|
1704 data->Des().Copy(KHello); |
|
1705 CleanupStack::Pop(data); |
|
1706 |
|
1707 TRtpSendPktParams *headerinfo = new(ELeave) TRtpSendPktParams(header); |
|
1708 headerinfo->iTranStreamId = err; |
|
1709 headerinfo->iPayloadData.Set(data->Des()); |
|
1710 |
|
1711 const TUint KArrayGranularity = 15; |
|
1712 |
|
1713 CArrayFixFlat<TUint32>* fix; |
|
1714 fix = new(ELeave) CArrayFixFlat<TUint32>(KArrayGranularity); |
|
1715 |
|
1716 fix->AppendL(123456); |
|
1717 fix->AppendL(999999); |
|
1718 |
|
1719 TInt error3( KErrNone ); |
|
1720 iIsCallBackReceived = EFalse; |
|
1721 // Try sending synchronously with Csrc |
|
1722 error3 = iRtpAPI->SendRtpPacket(*headerinfo, fix->Array()); |
|
1723 RTP_EUNIT_ASSERT_EQUALS ( error3, KErrNone ); |
|
1724 |
|
1725 CRtpSession* rtpSession = iRtpAPI->iManager->GetSession( err ); |
|
1726 User::WaitForRequest( rtpSession->iCommNet->iSender[ERTPPort]->iStatus ); |
|
1727 rtpSession->iCommNet->iSender[ERTPPort]->RunL(); |
|
1728 rtpSession->iCommNet->iSender[ERTPPort]->iStatus = TRequestStatus(); |
|
1729 EUNIT_ASSERT(iIsCallBackReceived == ETrue); |
|
1730 |
|
1731 // Unregister callback |
|
1732 iRtpAPI->UnregisterRtpPostProcessingObserver(error); |
|
1733 |
|
1734 iIsCallBackReceived = EFalse; |
|
1735 error3 = KErrNone; |
|
1736 // Try sending synchronously with Csrc |
|
1737 error3 = iRtpAPI->SendRtpPacket(*headerinfo, fix->Array()); |
|
1738 RTP_EUNIT_ASSERT_EQUALS ( error3, KErrNone ); |
|
1739 |
|
1740 User::WaitForRequest( rtpSession->iCommNet->iSender[ERTPPort]->iStatus ); |
|
1741 rtpSession->iCommNet->iSender[ERTPPort]->RunL(); |
|
1742 rtpSession->iCommNet->iSender[ERTPPort]->iStatus = TRequestStatus(); |
|
1743 EUNIT_ASSERT(iIsCallBackReceived == EFalse); |
|
1744 |
|
1745 delete fix; |
|
1746 delete headerinfo; |
|
1747 delete data; |
|
1748 } |
|
1749 |
1472 // TEST TABLE |
1750 // TEST TABLE |
1473 |
1751 |
1474 EUNIT_BEGIN_TEST_TABLE( |
1752 EUNIT_BEGIN_TEST_TABLE( |
1475 UT_CRtpAPI, |
1753 UT_CRtpAPI, |
1476 "Test CRtpAPI.", |
1754 "Test CRtpAPI.", |