winlin

for bug #241, refine the max buffer and kbps.

@@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 // use the bitrate in kbps to calc the max sleep time. 35 // use the bitrate in kbps to calc the max sleep time.
36 #define SRS_MR_MAX_BITRATE_KBPS 10000 36 #define SRS_MR_MAX_BITRATE_KBPS 10000
37 #define SRS_MR_AVERAGE_BITRATE_KBPS 1000 37 #define SRS_MR_AVERAGE_BITRATE_KBPS 1000
38 -#define SRS_MR_MIN_BITRATE_KBPS 64 38 +#define SRS_MR_MIN_BITRATE_KBPS 32
39 // the max sleep time in ms 39 // the max sleep time in ms
40 #define SRS_MR_MAX_SLEEP_MS 3000 40 #define SRS_MR_MAX_SLEEP_MS 3000
41 // the max small bytes to group 41 // the max small bytes to group
@@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 25
26 #include <srs_kernel_error.hpp> 26 #include <srs_kernel_error.hpp>
27 #include <srs_kernel_log.hpp> 27 #include <srs_kernel_log.hpp>
  28 +#include <srs_kernel_utility.hpp>
28 29
29 // 4KB=4096 30 // 4KB=4096
30 // 8KB=8192 31 // 8KB=8192
@@ -33,6 +34,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -33,6 +34,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 // 64KB=65536 34 // 64KB=65536
34 // @see https://github.com/winlinvip/simple-rtmp-server/issues/241 35 // @see https://github.com/winlinvip/simple-rtmp-server/issues/241
35 #define SOCKET_READ_SIZE 4096 36 #define SOCKET_READ_SIZE 4096
  37 +// the max buffer for user space socket buffer.
  38 +#define SOCKET_MAX_BUF 65536
36 39
37 IMergeReadHandler::IMergeReadHandler() 40 IMergeReadHandler::IMergeReadHandler()
38 { 41 {
@@ -127,8 +130,11 @@ void SrsBuffer::set_merge_read(bool v, int max_buffer, IMergeReadHandler* handle @@ -127,8 +130,11 @@ void SrsBuffer::set_merge_read(bool v, int max_buffer, IMergeReadHandler* handle
127 merged_read = v; 130 merged_read = v;
128 _handler = handler; 131 _handler = handler;
129 132
130 - if (v && max_buffer != nb_buffer) {  
131 - reset_buffer(max_buffer); 133 + // limit the max buffer.
  134 + int buffer_size = srs_min(max_buffer, SOCKET_MAX_BUF);
  135 +
  136 + if (v && buffer_size != nb_buffer) {
  137 + reset_buffer(buffer_size);
132 } 138 }
133 } 139 }
134 140