之前模拟了如何通过增加一个RFC3984的mediawriter模块实现.264的数据发送动作。但还缺少音频部分的操作。现把这部分补齐,把这个类添加到stagefright框架里去的代码在上两篇有描述这里不再多说,只是贴出代码,以备忘:
RFC3984Writer(int fd);
virtual status_t addSource(const sp<MediaSource> &source);
virtual bool reachedEOS();
virtual status_t start(MetaData *params);
virtual status_t stop();
virtual status_t pause();
//virtual void onMessageReceived(const sp<AMessage> &msg);
virtual ~RFC3984Writer();
class Track;
Mutex mLock;
bool mPaused;
bool mStarted;
// Writer thread + track threads started successfully
//Condition mCondition;
AString muri;
status_t startTracks(MetaData *params);
int mRTPFd;
int mRTCPFd;
void dumpSessionDesc();
//DISALLOW_EVIL_CONSTRUCTORS(RFC3984Writer);
1.
RFC3984Writer.h
#ifndef A_RFC3984WRITER_H_
#define A_RFC3984WRITER_H_
#include <media/stagefright/foundation/ABase.h>
#include <media/stagefright/foundation/AHandlerReflector.h>
#include <media/stagefright/foundation/AString.h>
#include <media/stagefright/foundation/base64.h>
#include <media/stagefright/MediaWriter.h>
//#include <ortp/ortp.h>
//#include <ortp/rfc3984.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#define LOG_TO_FILES
0
namespace android {
struct ABuffer;
struct MediaBuffer;
struct RFC3984Writer : public MediaWriter {
// RFC3984Writer(const AString &uri);//IP:UDP-port
protected:
private:
int mFd;
void release();
List<Track *> mTracks;
#if LOG_TO_FILES
#endif
#if 0
#endif
};
}
// namespace android
#endif
// A_RFC3984WRITER_H_