SRS 6.0-b0 源码 + danmaku 后端(排除 objs/3rdparty/测试媒体)

This commit is contained in:
RRRosmontis
2026-08-27 21:46:20 +08:00
commit 41b5da7c7e
578 changed files with 237858 additions and 0 deletions
+91
View File
@@ -0,0 +1,91 @@
#!/usr/bin/python
#
# Copyright (c) 2013-2025 Winlin
#
# SPDX-License-Identifier: MIT
#
#################################################################################
# to stat the code and comments lines
#################################################################################
import sys
def trace(msg):
print msg
pass
def info(msg):
print msg
pass
def verbose(msg):
#print msg
pass
def process(f, code_file):
info("process file success")
(stat_code, stat_block_comments, stat_line_comments) = (0, 0, 0)
is_block_comments = False
is_line_comments = False
for line in f.readlines():
line = line.strip()
if is_block_comments:
if "*/" in line:
verbose("[block][end] %s"%line)
is_block_comments = False
is_line_comments = False
else:
verbose("[block][cont] %s"%line)
stat_block_comments += 1
continue
if line.startswith("/*"):
verbose("[block][start] %s"%line)
is_block_comments = True
is_line_comments = False
stat_block_comments += 1
# inline block comments
if is_block_comments:
if "*/" in line:
verbose("[block][end] %s"%line)
is_block_comments = False
is_line_comments = False
continue
if line.startswith("//"):
verbose("[line] %s"%line)
is_block_comments = False
is_line_comments = True
stat_line_comments += 1
continue
verbose("[code] %s"%line)
is_block_comments = False
is_line_comments = False
stat_code += 1
total = stat_code + stat_block_comments + stat_line_comments
comments = stat_block_comments + stat_line_comments
trace("total:%s code:%s comments:%s block:%s line:%s file:%s"%(total, stat_code, comments, stat_block_comments, stat_line_comments, code_file))
return (0, total, stat_code, comments, stat_block_comments, stat_line_comments, code_file)
def do_stat(code_file):
f = None
try:
f = open(code_file, "r")
info("open file success");
return process(f, code_file)
finally:
if f is not None:
f.close()
info("close file success")
return (-1, 0, 0, 0, 0, 0, None)
code_file = None
if __name__ == "__main__":
if len(sys.argv) <= 1:
print "to stat the code and comments lines"
print "Usage: python %s <code_file>"%(sys.argv[0])
print " code_file: the code(header or source) file to stat"
print "Example:"
print " python %s src/core/srs_core.hpp"%(sys.argv[0])
sys.exit(-1)
code_file = sys.argv[1]
info("stat %s"%(code_file))
do_stat(code_file)
+77
View File
@@ -0,0 +1,77 @@
#!/usr/bin/python
#
# Copyright (c) 2013-2025 Winlin
#
# SPDX-License-Identifier: MIT
#
#################################################################################
# to stat the code and comments lines
#################################################################################
import sys, os, cs
from cs import info, trace
if __name__ != "__main__":
print "donot support lib"
sys.exit(-1)
filters="*.*pp,*.h,*.c,*.cc"
except_filters="utest,doc"
if len(sys.argv) <= 1:
print "to stat the code and comments lines"
print "Usage: python %s <dir> [filters] [except_filters]"%(sys.argv[0])
print " dir: the dir contains the files to stat"
print " filters: the file filters, default: *.*pp,*.h,*.c,*.cc"
print " except_filters: the except file filters, default: utest,doc"
print "Example:"
print " python %s src"%(sys.argv[0])
print " python %s src *.*pp,*.cc utest,doc"%(sys.argv[0])
sys.exit(-1)
dir = sys.argv[1]
if len(sys.argv) > 2:
filters = sys.argv[2]
if len(sys.argv) > 3:
except_filters = sys.argv[3]
info("stat dir:%s, filters:%s, except_filters:%s"%(dir, filters, except_filters))
# filters to array
filters = filters.split(",")
except_filters = except_filters.split(",")
# find src -name "*.*pp"|grep -v utest
(totals, stat_codes, commentss, stat_block_commentss, stat_line_commentss) = (0, 0, 0, 0, 0)
for filter in filters:
cmd = 'find %s -name "%s"'%(dir, filter)
for ef in except_filters:
cmd = '%s|%s'%(cmd, 'grep -v "%s"'%(ef))
cmd = "%s 2>&1"%(cmd)
info("scan dir, cmd:%s"%cmd)
pipe = os.popen(cmd)
files = pipe.read()
info("scan dir, files:%s"%files)
pipe.close()
files = files.split("\n")
for file in files:
file = file.strip()
if len(file) == 0:
continue;
info("start stat file:%s"%file)
(code, total, stat_code, comments, stat_block_comments, stat_line_comments, code_file) = cs.do_stat(file)
if code != 0:
continue;
totals += total
stat_codes += stat_code
commentss += comments
stat_block_commentss += stat_block_comments
stat_line_commentss += stat_line_comments
if totals == 0:
trace("no code or comments found.")
else:
trace("total:%s code:%s comments:%s(%.2f%%) block:%s line:%s"%(
totals, stat_codes, commentss, commentss * 100.0 / totals, stat_block_commentss, stat_line_commentss
))