Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4bcec5dc authored by Somraj Mani's avatar Somraj Mani Committed by Lajos Molnar
Browse files

VT: Retain RTP sequence number between SFR stop and start



There was an issue that remote side dropped a video packets
when local camera has been switched.

It caused we are sending discontinuous (RTP) sequence number
when the camera is switched during video call is going on.

When we switch a camera, we just stopped a MediaRecorder
and then re-start with different camera-id.

RTP sequence number is gone when an ARTPWriter is stopped.
and Then ARTPWriter will take a random RTP sequence number from
the re-start of ARTPWriter.

This patch makes ARTPWriter can start from the RTP sequence number
that the stopped last time.

Merged-in: I7dde2c89f2b378600a080b7a4f4de385f81e6ee1
Change-Id: I7dde2c89f2b378600a080b7a4f4de385f81e6ee1
Signed-off-by: default avatarSomraj Mani <som.mani@samsung.com>
Signed-off-by: default avatarKim Sungyeon <sy85.kim@samsung.com>
parent 9a021f7f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ StagefrightRecorder::StagefrightRecorder(const String16 &opPackageName)
      mVideoSource(VIDEO_SOURCE_LIST_END),
      mRTPCVOExtMap(-1),
      mRTPCVODegrees(0),
      mLastSeqNo(0),
      mStarted(false),
      mSelectedDeviceId(AUDIO_PORT_HANDLE_NONE),
      mDeviceCallbackEnabled(false),
@@ -1474,7 +1475,7 @@ status_t StagefrightRecorder::setupRTPRecording() {
        mVideoEncoderSource = source;
    }

    mWriter = new ARTPWriter(mOutputFd, mLocalIp, mLocalPort, mRemoteIp, mRemotePort);
    mWriter = new ARTPWriter(mOutputFd, mLocalIp, mLocalPort, mRemoteIp, mRemotePort, mLastSeqNo);
    mWriter->addSource(source);
    mWriter->setListener(mListener);

@@ -2274,6 +2275,7 @@ status_t StagefrightRecorder::stop() {

    if (mWriter != NULL) {
        err = mWriter->stop();
        mLastSeqNo = mWriter->getSequenceNum();
        mWriter.clear();
    }

+1 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ private:
    int32_t mPayloadType;
    int32_t mRTPCVOExtMap;
    int32_t mRTPCVODegrees;
    uint32_t mLastSeqNo;

    int64_t mDurationRecordedUs;
    int64_t mStartedRecordingUs;
+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ struct MediaWriter : public RefBase {
    virtual status_t setNextFd(int /*fd*/) { return INVALID_OPERATION; }
    virtual void updateCVODegrees(int32_t /*cvoDegrees*/) {}
    virtual void updatePayloadType(int32_t /*payloadType*/) {}
    virtual uint32_t getSequenceNum() { return 0; }

protected:
    virtual ~MediaWriter() {}
+12 −3
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ ARTPWriter::ARTPWriter(int fd)
}

ARTPWriter::ARTPWriter(int fd, String8& localIp, int localPort, String8& remoteIp,
    int remotePort)
    int remotePort, uint32_t seqNo)
    : mFlags(0),
      mFd(dup(fd)),
      mLooper(new ALooper),
@@ -129,6 +129,8 @@ ARTPWriter::ARTPWriter(int fd, String8& localIp, int localPort, String8& remoteI
    mSPSBuf = NULL;
    mPPSBuf = NULL;

    mSeqNo = seqNo;

#if LOG_TO_FILES
    mRTPFd = open(
            "/data/misc/rtpout.bin",
@@ -192,6 +194,7 @@ status_t ARTPWriter::start(MetaData * params) {
    mFlags &= ~kFlagEOS;
    if (mSourceID == 0)
        mSourceID = rand();
    if (mSeqNo == 0)
        mSeqNo = UniformRand(65536);
    mRTPTimeBase = 0;
    mNumRTPSent = 0;
@@ -336,7 +339,9 @@ void ARTPWriter::onMessageReceived(const sp<AMessage> &msg) {
    switch (msg->what()) {
        case kWhatStart:
        {
            CHECK_EQ(mSource->start(), (status_t)OK);
            sp<MetaData> meta = new MetaData();
            meta->setInt64(kKeyTime, 10ll);
            CHECK_EQ(mSource->start(meta.get()), (status_t)OK);

#if 0
            if (mMode == H264) {
@@ -1170,6 +1175,10 @@ void ARTPWriter::updatePayloadType(int32_t payloadType) {
    mPayloadType = payloadType;
}

uint32_t ARTPWriter::getSequenceNum() {
    return mSeqNo;
}

static size_t getFrameSize(bool isWide, unsigned FT) {
    static const size_t kFrameSizeNB[8] = {
        95, 103, 118, 134, 148, 159, 204, 244
+3 −1
Original line number Diff line number Diff line
@@ -37,7 +37,8 @@ class MediaBuffer;
struct ARTPWriter : public MediaWriter {
    explicit ARTPWriter(int fd);
    explicit ARTPWriter(int fd, String8& localIp, int localPort,
                                String8& remoteIp, int remotePort);
                                String8& remoteIp, int remotePort,
                                uint32_t seqNo);

    virtual status_t addSource(const sp<MediaSource> &source);
    virtual bool reachedEOS();
@@ -46,6 +47,7 @@ struct ARTPWriter : public MediaWriter {
    virtual status_t pause();
    void updateCVODegrees(int32_t cvoDegrees);
    void updatePayloadType(int32_t payloadType);
    uint32_t getSequenceNum();

    virtual void onMessageReceived(const sp<AMessage> &msg);
    virtual void setTMMBNInfo(uint32_t opponentID, uint32_t bitrate);