2021-05-31 05:42:20 +00:00
|
|
|
//
|
2021-07-08 06:30:47 +00:00
|
|
|
// Copyright (c) 2013-2021 The SRS Authors
|
2021-05-31 05:42:20 +00:00
|
|
|
//
|
2022-01-13 10:40:17 +00:00
|
|
|
// SPDX-License-Identifier: MIT or MulanPSL-2.0
|
2021-05-31 05:42:20 +00:00
|
|
|
//
|
2014-06-22 12:01:25 +00:00
|
|
|
|
2015-09-22 01:15:51 +00:00
|
|
|
#ifndef SRS_PROTOCOL_MESSAGE_ARRAY_HPP
|
|
|
|
#define SRS_PROTOCOL_MESSAGE_ARRAY_HPP
|
2014-06-22 12:01:25 +00:00
|
|
|
|
|
|
|
#include <srs_core.hpp>
|
|
|
|
|
2014-12-05 15:03:52 +00:00
|
|
|
class SrsSharedPtrMessage;
|
2014-06-22 12:01:25 +00:00
|
|
|
|
2019-04-23 00:06:50 +00:00
|
|
|
// The class to auto free the shared ptr message array.
|
|
|
|
// When need to get some messages, for instance, from Consumer queue,
|
|
|
|
// create a message array, whose msgs can used to accept the msgs,
|
|
|
|
// then send each message and set to NULL.
|
|
|
|
//
|
|
|
|
// @remark: user must free all msgs in array, for the SRS2.0 protocol stack
|
|
|
|
// provides an api to send messages, @see send_and_free_messages
|
2014-11-13 08:56:41 +00:00
|
|
|
class SrsMessageArray
|
2014-06-22 12:01:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-04-23 00:06:50 +00:00
|
|
|
// When user already send all msgs, please set to NULL,
|
|
|
|
// for instance, msg= msgs.msgs[i], msgs.msgs[i]=NULL, send(msg),
|
|
|
|
// where send(msg) will always send and free it.
|
2014-12-05 15:03:52 +00:00
|
|
|
SrsSharedPtrMessage** msgs;
|
2014-11-14 03:24:49 +00:00
|
|
|
int max;
|
2014-06-22 12:01:25 +00:00
|
|
|
public:
|
2019-04-23 00:06:50 +00:00
|
|
|
// Create msg array, initialize array to NULL ptrs.
|
2014-11-14 03:24:49 +00:00
|
|
|
SrsMessageArray(int max_msgs);
|
2019-04-23 00:06:50 +00:00
|
|
|
// Free the msgs not sent out(not NULL).
|
2014-11-13 08:56:41 +00:00
|
|
|
virtual ~SrsMessageArray();
|
2014-12-05 08:44:11 +00:00
|
|
|
public:
|
2019-04-23 00:06:50 +00:00
|
|
|
// Free specified count of messages.
|
2014-12-05 08:44:11 +00:00
|
|
|
virtual void free(int count);
|
|
|
|
private:
|
2019-04-23 00:06:50 +00:00
|
|
|
// Zero initialize the message array.
|
2014-12-05 08:44:11 +00:00
|
|
|
virtual void zero(int count);
|
2014-06-22 12:01:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2014-08-02 14:18:39 +00:00
|
|
|
|